From de1961c0d21aacb193e80b3faf7e76f5251b9e44 Mon Sep 17 00:00:00 2001 From: TkDodo Date: Mon, 23 Mar 2026 13:59:41 +0100 Subject: [PATCH 1/3] fix(timeout): make sure NodeJs.Timout doesn't leak --- packages/query-core/src/timeoutManager.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/query-core/src/timeoutManager.ts b/packages/query-core/src/timeoutManager.ts index 97f0870eea2..6f74050b04c 100644 --- a/packages/query-core/src/timeoutManager.ts +++ b/packages/query-core/src/timeoutManager.ts @@ -28,9 +28,9 @@ export type TimeoutProvider = readonly clearInterval: (intervalId: TTimerId | undefined) => void } -export const defaultTimeoutProvider: TimeoutProvider< - ReturnType -> = { +type SystemTimerId = ReturnType + +export const defaultTimeoutProvider: TimeoutProvider = { // We need the wrapper function syntax below instead of direct references to // global setTimeout etc. // @@ -42,10 +42,12 @@ export const defaultTimeoutProvider: TimeoutProvider< // have a hard reference to the original implementation at the time when this // file was imported. setTimeout: (callback, delay) => setTimeout(callback, delay), - clearTimeout: (timeoutId) => clearTimeout(timeoutId), + clearTimeout: (timeoutId) => + clearTimeout(timeoutId as SystemTimerId | undefined), setInterval: (callback, delay) => setInterval(callback, delay), - clearInterval: (intervalId) => clearInterval(intervalId), + clearInterval: (intervalId) => + clearInterval(intervalId as SystemTimerId | undefined), } /** @@ -62,7 +64,8 @@ export const defaultTimeoutProvider: TimeoutProvider< export class TimeoutManager implements Omit { // We cannot have TimeoutManager as we must instantiate it with a concrete // type at app boot; and if we leave that type, then any new timer provider - // would need to support ReturnType, which is infeasible. + // would need to support the default provider's concrete timer ID, which is + // infeasible across environments. // // We settle for type safety for the TimeoutProvider type, and accept that // this class is unsafe internally to allow for extension. From fd00b500e748c4a6965a41a3990546099e67f0f5 Mon Sep 17 00:00:00 2001 From: TkDodo Date: Mon, 23 Mar 2026 14:00:28 +0100 Subject: [PATCH 2/3] changeset --- .changeset/funny-views-build.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/funny-views-build.md diff --git a/.changeset/funny-views-build.md b/.changeset/funny-views-build.md new file mode 100644 index 00000000000..524b36bfe36 --- /dev/null +++ b/.changeset/funny-views-build.md @@ -0,0 +1,5 @@ +--- +'@tanstack/query-core': patch +--- + +fix(timeoutManager): make sure NodeJs.Timout doesn't leak From ad614cb6aa96fc1a8fbd7201dc5e5607c3b3a850 Mon Sep 17 00:00:00 2001 From: TkDodo Date: Mon, 23 Mar 2026 15:39:23 +0100 Subject: [PATCH 3/3] fix(tsconfig): include src directory in production configuration --- packages/preact-query/tsconfig.prod.json | 1 + packages/query-core/tsconfig.prod.json | 4 +++- packages/react-query/tsconfig.prod.json | 1 + packages/solid-query/tsconfig.prod.json | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/preact-query/tsconfig.prod.json b/packages/preact-query/tsconfig.prod.json index c2c63818c2d..2bb29fdf02a 100644 --- a/packages/preact-query/tsconfig.prod.json +++ b/packages/preact-query/tsconfig.prod.json @@ -5,5 +5,6 @@ "composite": false, "rootDir": "../../" }, + "include": ["src"], "exclude": ["src/__tests__"] } diff --git a/packages/query-core/tsconfig.prod.json b/packages/query-core/tsconfig.prod.json index 0f4c92da065..2bb29fdf02a 100644 --- a/packages/query-core/tsconfig.prod.json +++ b/packages/query-core/tsconfig.prod.json @@ -4,5 +4,7 @@ "incremental": false, "composite": false, "rootDir": "../../" - } + }, + "include": ["src"], + "exclude": ["src/__tests__"] } diff --git a/packages/react-query/tsconfig.prod.json b/packages/react-query/tsconfig.prod.json index c2c63818c2d..2bb29fdf02a 100644 --- a/packages/react-query/tsconfig.prod.json +++ b/packages/react-query/tsconfig.prod.json @@ -5,5 +5,6 @@ "composite": false, "rootDir": "../../" }, + "include": ["src"], "exclude": ["src/__tests__"] } diff --git a/packages/solid-query/tsconfig.prod.json b/packages/solid-query/tsconfig.prod.json index c2c63818c2d..2bb29fdf02a 100644 --- a/packages/solid-query/tsconfig.prod.json +++ b/packages/solid-query/tsconfig.prod.json @@ -5,5 +5,6 @@ "composite": false, "rootDir": "../../" }, + "include": ["src"], "exclude": ["src/__tests__"] }