Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-views-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/query-core': patch
---

fix(timeoutManager): make sure NodeJs.Timout doesn't leak
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in release note text (NodeJs.Timout).

Please correct the type name to avoid publishing a misspelled changelog entry.

✏️ Proposed patch
-fix(timeoutManager): make sure NodeJs.Timout doesn't leak
+fix(timeoutManager): make sure NodeJS.Timeout doesn't leak
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fix(timeoutManager): make sure NodeJs.Timout doesn't leak
fix(timeoutManager): make sure NodeJS.Timeout doesn't leak
🧰 Tools
🪛 LanguageTool

[grammar] ~5-~5: Ensure spelling is correct
Context: ... fix(timeoutManager): make sure NodeJs.Timout doesn't leak

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/funny-views-build.md at line 5, The release note contains a typo:
the type name is written as "NodeJs.Timout"; update that string to the correct
TypeScript runtime type "NodeJS.Timeout" (capital JS and correct spelling of
Timeout) so the changelog entry reads "fix(timeoutManager): make sure
NodeJS.Timeout doesn't leak".

15 changes: 9 additions & 6 deletions packages/query-core/src/timeoutManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =
readonly clearInterval: (intervalId: TTimerId | undefined) => void
}

export const defaultTimeoutProvider: TimeoutProvider<
ReturnType<typeof setTimeout>
> = {
type SystemTimerId = ReturnType<typeof setTimeout>

export const defaultTimeoutProvider: TimeoutProvider = {
// We need the wrapper function syntax below instead of direct references to
// global setTimeout etc.
//
Expand All @@ -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),
}

/**
Expand All @@ -62,7 +64,8 @@ export const defaultTimeoutProvider: TimeoutProvider<
export class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
// We cannot have TimeoutManager<T> 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<typeof setTimeout>, 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.
Expand Down
Loading