Skip to content

Commit

Permalink
Patch trpc batching (#7555)
Browse files Browse the repository at this point in the history
  • Loading branch information
stereosteve authored Feb 12, 2024
1 parent 85181d0 commit 28c70fa
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"install-hooks": "mookme init --only-hook --skip-types-selection",
"lint:fix": "turbo run lint:fix",
"lint": "turbo run lint",
"patch-package": "patch-package --patch-dir=packages/mobile/patches && patch-package --patch-dir=packages/web/patches && patch-package --patch-dir=packages/identity-service/patches",
"patch-package": "patch-package && patch-package --patch-dir=packages/mobile/patches && patch-package --patch-dir=packages/web/patches && patch-package --patch-dir=packages/identity-service/patches",
"postinstall": "bash ./scripts/postinstall.sh",
"preinstall": "bash ./scripts/preinstall.sh",
"turbo-link": "turbo login && turbo link",
Expand Down Expand Up @@ -113,4 +113,4 @@
"webpack": "5.88.2"
},
"packageManager": "[email protected]"
}
}
12 changes: 11 additions & 1 deletion packages/web/src/app/TrpcProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ type TrpcProviderProps = {
export const TrpcProvider = (props: TrpcProviderProps) => {
const { children } = props
const currentUserId = useSelector(accountSelectors.getUserId)
const [queryClient] = useState(() => new QueryClient())
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
staleTime: 1000 * 20
}
}
})
)
const trpcClient = useMemo(
() => createAudiusTrpcClient(currentUserId),
[currentUserId]
Expand Down
39 changes: 39 additions & 0 deletions patches/@trpc+client+10.38.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/node_modules/@trpc/client/dist/httpBatchLink-78d2f90a.js b/node_modules/@trpc/client/dist/httpBatchLink-78d2f90a.js
index b83ca37..98b3945 100644
--- a/node_modules/@trpc/client/dist/httpBatchLink-78d2f90a.js
+++ b/node_modules/@trpc/client/dist/httpBatchLink-78d2f90a.js
@@ -115,7 +115,7 @@ var httpUtils = require('./httpUtils-b0a649f7.js');
pendingItems.push(item);
});
if (!dispatchTimer) {
- dispatchTimer = setTimeout(dispatch);
+ dispatchTimer = setTimeout(dispatch, 500);
}
const cancel = ()=>{
item.aborted = true;
diff --git a/node_modules/@trpc/client/dist/httpBatchLink-abfe4d66.js b/node_modules/@trpc/client/dist/httpBatchLink-abfe4d66.js
index ac88ce5..195fa42 100644
--- a/node_modules/@trpc/client/dist/httpBatchLink-abfe4d66.js
+++ b/node_modules/@trpc/client/dist/httpBatchLink-abfe4d66.js
@@ -117,7 +117,7 @@ function dataLoader(batchLoader) {
pendingItems.push(item);
});
if (!dispatchTimer) {
- dispatchTimer = setTimeout(dispatch);
+ dispatchTimer = setTimeout(dispatch, 500);
}
const cancel = () => {
item.aborted = true;
diff --git a/node_modules/@trpc/client/dist/httpBatchLink-cee1f56c.mjs b/node_modules/@trpc/client/dist/httpBatchLink-cee1f56c.mjs
index cf9a88a..74083eb 100644
--- a/node_modules/@trpc/client/dist/httpBatchLink-cee1f56c.mjs
+++ b/node_modules/@trpc/client/dist/httpBatchLink-cee1f56c.mjs
@@ -113,7 +113,7 @@ import { r as resolveHTTPLinkOptions, g as getUrl, j as jsonHttpRequester } from
pendingItems.push(item);
});
if (!dispatchTimer) {
- dispatchTimer = setTimeout(dispatch);
+ dispatchTimer = setTimeout(dispatch, 500);
}
const cancel = ()=>{
item.aborted = true;

0 comments on commit 28c70fa

Please sign in to comment.