-
Notifications
You must be signed in to change notification settings - Fork 25k
Incorporate timers into main Node.js lib defs and align with v24 #55079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+77
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Job Summary for GradleTest All :: run_fantom_tests
|
) Summary: This is an AI-assisted change to consolidate Metro's separate `node.js` file into the main Node.js library definitions and align with Node.js v24 (effectively v22) standards. **Consolidation Changes:** 1. **Incorporated Separate File** - Removed duplication - Moved definitions from `xplat/js/tools/metro/flow-typed/node.js` into main `node.js` files - Deleted the separate node.js file (no longer needed) - Both Metro and React Native now use unified definitions - Positioned alphabetically between 'tls' and 'url' modules **Timeout Class Enhancements:** 2. **Complete Timeout Class** - All timer management methods - `close()` - Cancels the timeout (added in v0.9.1) - `hasRef()` - Returns true if timer will keep Node.js running (added in v11.0.0) - `ref()` - Request timer keep Node.js running (added in v0.9.1) - `refresh()` - Refresh timer's start time (added in v10.2.0) - `unref()` - Allow Node.js to exit if timer is only active thing (added in v0.9.1) - `[Symbol.toPrimitive]` - Get numeric timer ID (added in v14.9.0) - Uses `[key: $SymbolToPrimitive]` syntax - https://nodejs.org/api/timers.html#class-timeout **Immediate Class Enhancements:** 3. **Complete Immediate Class** - Immediate timer management - `hasRef()` - Returns true if immediate will keep Node.js running (added in v11.0.0) - `ref()` - Request immediate keep Node.js running (added in v9.7.0, v8.12.0) - `unref()` - Allow Node.js to exit if immediate is only active thing (added in v9.7.0, v8.12.0) - https://nodejs.org/api/timers.html#class-immediate **Core Timer Functions:** 4. **setTimeout/setInterval/setImmediate** - Complete signatures - Generic `<TArgs: Iterable<mixed>>` for type-safe callback arguments - `setTimeout(callback, delay?, ...args)` - Returns `Timeout` - `setInterval(callback, delay?, ...args)` - Returns `Timeout` - `setImmediate(callback, ...args)` - Returns `Immediate` - All support passing additional arguments to callback - https://nodejs.org/api/timers.html#settimeoutcallback-delay-args 5. **Clear Functions** - Flexible cancellation - `clearTimeout(timeout?)` - Accepts `Timeout` or numeric ID - `clearInterval(timeout?)` - Accepts `Timeout` or numeric ID - `clearImmediate(immediate?)` - Accepts `Immediate` or numeric ID - All parameters optional (no-op if not provided) - https://nodejs.org/api/timers.html#cleartimeouttimeout **Promises API (timers/promises):** 6. **Promise-based Timers** - Async/await compatible - `setTimeout<T>(delay?, value?, options?)` - Returns `Promise<T>` (added in v15.0.0) - `setImmediate<T>(value?, options?)` - Returns `Promise<T>` (added in v15.0.0) - `setInterval<T>(delay?, value?, options?)` - Returns `AsyncIterator<T>` (added in v15.9.0) - All support AbortSignal for cancellation - https://nodejs.org/api/timers.html#timers-promises-api 7. **TimerOptions Type** - Modern options object - `ref?: boolean` - Control if timer keeps Node.js running - `signal?: AbortSignal` - Abort controller for cancellation - Type uses `Readonly<{...}>` for input immutability - https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options 8. **setInterval as AsyncIterator** - Async iteration support (added in v15.9.0) - Returns `AsyncIterator<T>` instead of `Promise<T>` - Enables `for await (const value of setInterval(100, data))` patterns - Useful for periodic async operations - https://nodejs.org/api/timers.html#timerspromisessetintervaldelay-value-options **Scheduler API:** 9. **scheduler object** - Task scheduling utilities (added in v16.0.0) - `scheduler.wait(delay, options?)` - Promise-based delay (alternative to setTimeout) - `scheduler.yield()` - Yield to event loop (microtask yield) - Object marked as `Readonly<{...}>` for immutability - https://nodejs.org/api/timers.html#timerspromisesschedulerwaitdelay-options **Type Safety Improvements:** 10. **Readonly Input Types** - Applied consistently - `TimerOptions`: `Readonly<{ref?, signal?}>` - `scheduler` object: `Readonly<{wait, yield}>` - Allows passing readonly types safely (inputs should be readonly) 11. **Generic Type Parameters** - Type-safe callbacks - Timer functions: `<TArgs: Iterable<mixed>>` for variadic args - Promises API: `<T>` for resolved value types - Default generic: `<T = void>` for setInterval iterator 12. **Export Type Aliases** - Better developer experience - `Timeout` and `Immediate` exported as types from module - Consistent `timers$` prefix for internal types - Clean module exports without duplication **Symbol Support:** 13. **Symbol.toPrimitive** - Convert Timeout to number (added in v14.9.0) - Allows implicit conversion: `Number(timeout)` or `+timeout` - Returns the numeric timer ID - Flow syntax: `[key: $SymbolToPrimitive]: () => number` - https://nodejs.org/api/timers.html#timeoutsymboltoprimitive **Flow Limitations:** 14. **Symbol.dispose not included** - Explicit resource management - `[key: $SymbolDispose]: () => void` is commented out - Node.js added Symbol.dispose in v18.18.0, v20.4.0 - Flow doesn't fully support this symbol yet or has issues with multiple symbol-keyed properties - Will be enabled when Flow support improves - https://nodejs.org/api/timers.html#timeoutsymboldispose **References:** - Node.js timers module docs: https://nodejs.org/api/timers.html - TC39 Explicit Resource Management: https://github.com/tc39/proposal-explicit-resource-management Changelog: [Internal] --- > Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/) [Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace) Reviewed By: vzaidman Differential Revision: D89944814
facebook-github-bot
pushed a commit
that referenced
this pull request
Jan 7, 2026
) Summary: This is an AI-assisted change to consolidate Metro's separate `node.js` file into the main Node.js library definitions and align with Node.js v24 (effectively v22) standards. **Consolidation Changes:** 1. **Incorporated Separate File** - Removed duplication - Moved definitions from `xplat/js/tools/metro/flow-typed/node.js` into main `node.js` files - Deleted the separate node.js file (no longer needed) - Both Metro and React Native now use unified definitions - Positioned alphabetically between 'tls' and 'url' modules **Timeout Class Enhancements:** 2. **Complete Timeout Class** - All timer management methods - `close()` - Cancels the timeout (added in v0.9.1) - `hasRef()` - Returns true if timer will keep Node.js running (added in v11.0.0) - `ref()` - Request timer keep Node.js running (added in v0.9.1) - `refresh()` - Refresh timer's start time (added in v10.2.0) - `unref()` - Allow Node.js to exit if timer is only active thing (added in v0.9.1) - `[Symbol.toPrimitive]` - Get numeric timer ID (added in v14.9.0) - Uses `[key: $SymbolToPrimitive]` syntax - https://nodejs.org/api/timers.html#class-timeout **Immediate Class Enhancements:** 3. **Complete Immediate Class** - Immediate timer management - `hasRef()` - Returns true if immediate will keep Node.js running (added in v11.0.0) - `ref()` - Request immediate keep Node.js running (added in v9.7.0, v8.12.0) - `unref()` - Allow Node.js to exit if immediate is only active thing (added in v9.7.0, v8.12.0) - https://nodejs.org/api/timers.html#class-immediate **Core Timer Functions:** 4. **setTimeout/setInterval/setImmediate** - Complete signatures - Generic `<TArgs: Iterable<mixed>>` for type-safe callback arguments - `setTimeout(callback, delay?, ...args)` - Returns `Timeout` - `setInterval(callback, delay?, ...args)` - Returns `Timeout` - `setImmediate(callback, ...args)` - Returns `Immediate` - All support passing additional arguments to callback - https://nodejs.org/api/timers.html#settimeoutcallback-delay-args 5. **Clear Functions** - Flexible cancellation - `clearTimeout(timeout?)` - Accepts `Timeout` or numeric ID - `clearInterval(timeout?)` - Accepts `Timeout` or numeric ID - `clearImmediate(immediate?)` - Accepts `Immediate` or numeric ID - All parameters optional (no-op if not provided) - https://nodejs.org/api/timers.html#cleartimeouttimeout **Promises API (timers/promises):** 6. **Promise-based Timers** - Async/await compatible - `setTimeout<T>(delay?, value?, options?)` - Returns `Promise<T>` (added in v15.0.0) - `setImmediate<T>(value?, options?)` - Returns `Promise<T>` (added in v15.0.0) - `setInterval<T>(delay?, value?, options?)` - Returns `AsyncIterator<T>` (added in v15.9.0) - All support AbortSignal for cancellation - https://nodejs.org/api/timers.html#timers-promises-api 7. **TimerOptions Type** - Modern options object - `ref?: boolean` - Control if timer keeps Node.js running - `signal?: AbortSignal` - Abort controller for cancellation - Type uses `Readonly<{...}>` for input immutability - https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options 8. **setInterval as AsyncIterator** - Async iteration support (added in v15.9.0) - Returns `AsyncIterator<T>` instead of `Promise<T>` - Enables `for await (const value of setInterval(100, data))` patterns - Useful for periodic async operations - https://nodejs.org/api/timers.html#timerspromisessetintervaldelay-value-options **Scheduler API:** 9. **scheduler object** - Task scheduling utilities (added in v16.0.0) - `scheduler.wait(delay, options?)` - Promise-based delay (alternative to setTimeout) - `scheduler.yield()` - Yield to event loop (microtask yield) - Object marked as `Readonly<{...}>` for immutability - https://nodejs.org/api/timers.html#timerspromisesschedulerwaitdelay-options **Type Safety Improvements:** 10. **Readonly Input Types** - Applied consistently - `TimerOptions`: `Readonly<{ref?, signal?}>` - `scheduler` object: `Readonly<{wait, yield}>` - Allows passing readonly types safely (inputs should be readonly) 11. **Generic Type Parameters** - Type-safe callbacks - Timer functions: `<TArgs: Iterable<mixed>>` for variadic args - Promises API: `<T>` for resolved value types - Default generic: `<T = void>` for setInterval iterator 12. **Export Type Aliases** - Better developer experience - `Timeout` and `Immediate` exported as types from module - Consistent `timers$` prefix for internal types - Clean module exports without duplication **Symbol Support:** 13. **Symbol.toPrimitive** - Convert Timeout to number (added in v14.9.0) - Allows implicit conversion: `Number(timeout)` or `+timeout` - Returns the numeric timer ID - Flow syntax: `[key: $SymbolToPrimitive]: () => number` - https://nodejs.org/api/timers.html#timeoutsymboltoprimitive **Flow Limitations:** 14. **Symbol.dispose not included** - Explicit resource management - `[key: $SymbolDispose]: () => void` is commented out - Node.js added Symbol.dispose in v18.18.0, v20.4.0 - Flow doesn't fully support this symbol yet or has issues with multiple symbol-keyed properties - Will be enabled when Flow support improves - https://nodejs.org/api/timers.html#timeoutsymboldispose **References:** - Node.js timers module docs: https://nodejs.org/api/timers.html - TC39 Explicit Resource Management: https://github.com/tc39/proposal-explicit-resource-management Changelog: [Internal] --- > Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/) [Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace) Reviewed By: vzaidman Differential Revision: D89944814
7e1f134 to
256cb26
Compare
Job Summary for GradleTest All :: run_fantom_tests
|
Collaborator
|
This pull request was successfully merged by @robhogan in a5fc307 When will my fix make it into a release? | How to file a pick request? |
|
This pull request has been merged in a5fc307. |
meta-codesync bot
pushed a commit
to facebook/metro
that referenced
this pull request
Jan 7, 2026
Summary: X-link: facebook/react-native#55079 This is an AI-assisted change to consolidate Metro's separate `node.js` file into the main Node.js library definitions and align with Node.js v24 (effectively v22) standards. **Consolidation Changes:** 1. **Incorporated Separate File** - Removed duplication - Moved definitions from `xplat/js/tools/metro/flow-typed/node.js` into main `node.js` files - Deleted the separate node.js file (no longer needed) - Both Metro and React Native now use unified definitions - Positioned alphabetically between 'tls' and 'url' modules **Timeout Class Enhancements:** 2. **Complete Timeout Class** - All timer management methods - `close()` - Cancels the timeout (added in v0.9.1) - `hasRef()` - Returns true if timer will keep Node.js running (added in v11.0.0) - `ref()` - Request timer keep Node.js running (added in v0.9.1) - `refresh()` - Refresh timer's start time (added in v10.2.0) - `unref()` - Allow Node.js to exit if timer is only active thing (added in v0.9.1) - `[Symbol.toPrimitive]` - Get numeric timer ID (added in v14.9.0) - Uses `[key: $SymbolToPrimitive]` syntax - https://nodejs.org/api/timers.html#class-timeout **Immediate Class Enhancements:** 3. **Complete Immediate Class** - Immediate timer management - `hasRef()` - Returns true if immediate will keep Node.js running (added in v11.0.0) - `ref()` - Request immediate keep Node.js running (added in v9.7.0, v8.12.0) - `unref()` - Allow Node.js to exit if immediate is only active thing (added in v9.7.0, v8.12.0) - https://nodejs.org/api/timers.html#class-immediate **Core Timer Functions:** 4. **setTimeout/setInterval/setImmediate** - Complete signatures - Generic `<TArgs: Iterable<mixed>>` for type-safe callback arguments - `setTimeout(callback, delay?, ...args)` - Returns `Timeout` - `setInterval(callback, delay?, ...args)` - Returns `Timeout` - `setImmediate(callback, ...args)` - Returns `Immediate` - All support passing additional arguments to callback - https://nodejs.org/api/timers.html#settimeoutcallback-delay-args 5. **Clear Functions** - Flexible cancellation - `clearTimeout(timeout?)` - Accepts `Timeout` or numeric ID - `clearInterval(timeout?)` - Accepts `Timeout` or numeric ID - `clearImmediate(immediate?)` - Accepts `Immediate` or numeric ID - All parameters optional (no-op if not provided) - https://nodejs.org/api/timers.html#cleartimeouttimeout **Promises API (timers/promises):** 6. **Promise-based Timers** - Async/await compatible - `setTimeout<T>(delay?, value?, options?)` - Returns `Promise<T>` (added in v15.0.0) - `setImmediate<T>(value?, options?)` - Returns `Promise<T>` (added in v15.0.0) - `setInterval<T>(delay?, value?, options?)` - Returns `AsyncIterator<T>` (added in v15.9.0) - All support AbortSignal for cancellation - https://nodejs.org/api/timers.html#timers-promises-api 7. **TimerOptions Type** - Modern options object - `ref?: boolean` - Control if timer keeps Node.js running - `signal?: AbortSignal` - Abort controller for cancellation - Type uses `Readonly<{...}>` for input immutability - https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options 8. **setInterval as AsyncIterator** - Async iteration support (added in v15.9.0) - Returns `AsyncIterator<T>` instead of `Promise<T>` - Enables `for await (const value of setInterval(100, data))` patterns - Useful for periodic async operations - https://nodejs.org/api/timers.html#timerspromisessetintervaldelay-value-options **Scheduler API:** 9. **scheduler object** - Task scheduling utilities (added in v16.0.0) - `scheduler.wait(delay, options?)` - Promise-based delay (alternative to setTimeout) - `scheduler.yield()` - Yield to event loop (microtask yield) - Object marked as `Readonly<{...}>` for immutability - https://nodejs.org/api/timers.html#timerspromisesschedulerwaitdelay-options **Type Safety Improvements:** 10. **Readonly Input Types** - Applied consistently - `TimerOptions`: `Readonly<{ref?, signal?}>` - `scheduler` object: `Readonly<{wait, yield}>` - Allows passing readonly types safely (inputs should be readonly) 11. **Generic Type Parameters** - Type-safe callbacks - Timer functions: `<TArgs: Iterable<mixed>>` for variadic args - Promises API: `<T>` for resolved value types - Default generic: `<T = void>` for setInterval iterator 12. **Export Type Aliases** - Better developer experience - `Timeout` and `Immediate` exported as types from module - Consistent `timers$` prefix for internal types - Clean module exports without duplication **Symbol Support:** 13. **Symbol.toPrimitive** - Convert Timeout to number (added in v14.9.0) - Allows implicit conversion: `Number(timeout)` or `+timeout` - Returns the numeric timer ID - Flow syntax: `[key: $SymbolToPrimitive]: () => number` - https://nodejs.org/api/timers.html#timeoutsymboltoprimitive **Flow Limitations:** 14. **Symbol.dispose not included** - Explicit resource management - `[key: $SymbolDispose]: () => void` is commented out - Node.js added Symbol.dispose in v18.18.0, v20.4.0 - Flow doesn't fully support this symbol yet or has issues with multiple symbol-keyed properties - Will be enabled when Flow support improves - https://nodejs.org/api/timers.html#timeoutsymboldispose **References:** - Node.js timers module docs: https://nodejs.org/api/timers.html - TC39 Explicit Resource Management: https://github.com/tc39/proposal-explicit-resource-management Changelog: [Internal] --- > Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/) [Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace) Reviewed By: vzaidman Differential Revision: D89944814 fbshipit-source-id: 38c1773d1a3591ef9f123681655720d17e7e53bb
Job Summary for GradleTest All :: run_fantom_tests
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
This PR has been merged.
meta-exported
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
This is an AI-assisted change to consolidate Metro's separate
node.jsfile into the main Node.js library definitions and align with Node.js v24 (effectively v22) standards.Consolidation Changes:
xplat/js/tools/metro/flow-typed/node.jsinto mainnode.jsfilesTimeout Class Enhancements:
close()- Cancels the timeout (added in v0.9.1)hasRef()- Returns true if timer will keep Node.js running (added in v11.0.0)ref()- Request timer keep Node.js running (added in v0.9.1)refresh()- Refresh timer's start time (added in v10.2.0)unref()- Allow Node.js to exit if timer is only active thing (added in v0.9.1)[Symbol.toPrimitive]- Get numeric timer ID (added in v14.9.0) - Uses[key: $SymbolToPrimitive]syntaxImmediate Class Enhancements:
hasRef()- Returns true if immediate will keep Node.js running (added in v11.0.0)ref()- Request immediate keep Node.js running (added in v9.7.0, v8.12.0)unref()- Allow Node.js to exit if immediate is only active thing (added in v9.7.0, v8.12.0)Core Timer Functions:
setTimeout/setInterval/setImmediate - Complete signatures
<TArgs: Iterable<mixed>>for type-safe callback argumentssetTimeout(callback, delay?, ...args)- ReturnsTimeoutsetInterval(callback, delay?, ...args)- ReturnsTimeoutsetImmediate(callback, ...args)- ReturnsImmediateClear Functions - Flexible cancellation
clearTimeout(timeout?)- AcceptsTimeoutor numeric IDclearInterval(timeout?)- AcceptsTimeoutor numeric IDclearImmediate(immediate?)- AcceptsImmediateor numeric IDPromises API (timers/promises):
Promise-based Timers - Async/await compatible
setTimeout<T>(delay?, value?, options?)- ReturnsPromise<T>(added in v15.0.0)setImmediate<T>(value?, options?)- ReturnsPromise<T>(added in v15.0.0)setInterval<T>(delay?, value?, options?)- ReturnsAsyncIterator<T>(added in v15.9.0)TimerOptions Type - Modern options object
ref?: boolean- Control if timer keeps Node.js runningsignal?: AbortSignal- Abort controller for cancellationReadonly<{...}>for input immutabilitysetInterval as AsyncIterator - Async iteration support (added in v15.9.0)
AsyncIterator<T>instead ofPromise<T>for await (const value of setInterval(100, data))patternsScheduler API:
scheduler.wait(delay, options?)- Promise-based delay (alternative to setTimeout)scheduler.yield()- Yield to event loop (microtask yield)Readonly<{...}>for immutabilityType Safety Improvements:
Readonly Input Types - Applied consistently
TimerOptions:Readonly<{ref?, signal?}>schedulerobject:Readonly<{wait, yield}>Generic Type Parameters - Type-safe callbacks
<TArgs: Iterable<mixed>>for variadic args<T>for resolved value types<T = void>for setInterval iteratorExport Type Aliases - Better developer experience
TimeoutandImmediateexported as types from moduletimers$prefix for internal typesSymbol Support:
Number(timeout)or+timeout[key: $SymbolToPrimitive]: () => numberFlow Limitations:
[key: $SymbolDispose]: () => voidis commented outReferences:
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D89944814