Skip to content

Align Flow lib defs for Node.js child_process with v24#55186

Closed
robhogan wants to merge 1 commit intomainfrom
export-D89944331
Closed

Align Flow lib defs for Node.js child_process with v24#55186
robhogan wants to merge 1 commit intomainfrom
export-D89944331

Conversation

@robhogan
Copy link
Copy Markdown
Contributor

Summary:
This is an AI-assisted change to align the Flow definitions for the child_process module with the Node.js docs as at v24.

New v18+ Features:

  1. AbortSignal Support (v18.0.0) - Process cancellation

  2. Enhanced Process Properties (v20.x)

ChildProcess Class Updates:

  1. Improved Property Types

    • stdio is now a properly typed tuple array with readonly modifier
    • channel changed from Object to mixed for better type safety
  2. Enhanced Method Signatures

Option Type Improvements:

  1. Modern Readonly Syntax - All input options use Readonly<{...}>

    • execOpts, execFileOpts, forkOpts, spawnOpts, spawnSyncOpts, etc.
    • Allows passing readonly types safely
  2. Enhanced Environment Variables

    • Changed env?: Object to env?: {[key: string]: string | void}
    • More precise typing for environment variable dictionaries
  3. New Fork Options (IPC enhancements)

  4. Enhanced Spawn Options

    • Added killSignal, timeout, serialization to spawnOpts
    • Better consistency across all spawn functions

Return Type Fixes:

  1. spawnRet/spawnSyncRet - Made fields properly nullable:
    • status: number | null - null if process never exited
    • signal: string | null - null if not terminated by signal
    • error: Error | void - void if no error occurred
    • Removed spread operator for exact types

Helper Types:

  1. child_process$Serializable - Union type for IPC messages:

    • string | number | boolean | bigint | {...} | Array<mixed>
    • Used in send() method signatures
  2. child_process$SendHandle - Type for handle passing:

    • net$Server | net$Socket
    • Used for passing server/socket handles to child processes

References:

Changelog: [Internal]

Generated by Confucius Code Assist (CCA)
Confucius Session, Trace

Reviewed By: vzaidman

Differential Revision: D89944331

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 15, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Jan 15, 2026

@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D89944331.

@github-actions
Copy link
Copy Markdown

Job Summary for Gradle

Test All :: run_fantom_tests
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
react-native-github :private:react-native-fantom:buildFantomTester 9.0.0 Build Scan not published

Summary:

This is an AI-assisted change to align the Flow definitions for the `child_process` module with the Node.js docs as at v24.

**New v18+ Features:**

1. **AbortSignal Support** (v18.0.0) - Process cancellation
   - Added `signal?: AbortSignal` option to all async functions (exec, execFile, fork, spawn)
   - Enables cancellation of child processes using `AbortController`
   - Example: `const controller = new AbortController(); spawn('cmd', [], {signal: controller.signal}); controller.abort();`
   - https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

2. **Enhanced Process Properties** (v20.x)
   - `spawnargs: Array<string>` - Full command-line arguments used to launch the process
   - `spawnfile: string` - Executable file name of the child process
   - `signalCode: string | null` - Signal that terminated the child process
   - https://nodejs.org/api/child_process.html#subprocessspawnargs

**ChildProcess Class Updates:**

3. **Improved Property Types**
   - `stdio` is now a properly typed tuple array with readonly modifier
   - `channel` changed from `Object` to `mixed` for better type safety

4. **Enhanced Method Signatures**
   - `kill(signal?: string | number): boolean` - Now returns boolean and accepts numeric signals
   - `send()` overloads properly typed with `child_process$Serializable` messages
   - `send()` accepts `keepOpen` option: `Readonly<{keepOpen?: boolean}>`
   - https://nodejs.org/api/child_process.html#subprocesskillsignal

**Option Type Improvements:**

6. **Modern Readonly Syntax** - All input options use `Readonly<{...}>`
   - `execOpts`, `execFileOpts`, `forkOpts`, `spawnOpts`, `spawnSyncOpts`, etc.
   - Allows passing readonly types safely

7. **Enhanced Environment Variables**
   - Changed `env?: Object` to `env?: {[key: string]: string | void}`
   - More precise typing for environment variable dictionaries

8. **New Fork Options** (IPC enhancements)
   - `serialization?: 'json' | 'advanced'` - IPC serialization format
   - `killSignal` and `timeout` options added to fork
   - https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options

9. **Enhanced Spawn Options**
   - Added `killSignal`, `timeout`, `serialization` to `spawnOpts`
   - Better consistency across all spawn functions

**Return Type Fixes:**

10. **spawnRet/spawnSyncRet** - Made fields properly nullable:
    - `status: number | null` - null if process never exited
    - `signal: string | null` - null if not terminated by signal
    - `error: Error | void` - void if no error occurred
    - Removed spread operator for exact types

**Helper Types:**

11. **`child_process$Serializable`** - Union type for IPC messages:
    - `string | number | boolean | bigint | {...} | Array<mixed>`
    - Used in send() method signatures

12. **`child_process$SendHandle`** - Type for handle passing:
    - `net$Server | net$Socket`
    - Used for passing server/socket handles to child processes

**References:**
- Node.js child_process module docs: https://nodejs.org/api/child_process.html
- AbortSignal integration: https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

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: D89944331
@meta-codesync meta-codesync bot closed this in 2e9b7fb Jan 18, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 18, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Jan 18, 2026

This pull request has been merged in 2e9b7fb.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @robhogan in 2e9b7fb

When will my fix make it into a release? | How to file a pick request?

meta-codesync bot pushed a commit to facebook/metro that referenced this pull request Jan 18, 2026
Summary:
X-link: facebook/react-native#55186

This is an AI-assisted change to align the Flow definitions for the `child_process` module with the Node.js docs as at v24.

**New v18+ Features:**

1. **AbortSignal Support** (v18.0.0) - Process cancellation
   - Added `signal?: AbortSignal` option to all async functions (exec, execFile, fork, spawn)
   - Enables cancellation of child processes using `AbortController`
   - Example: `const controller = new AbortController(); spawn('cmd', [], {signal: controller.signal}); controller.abort();`
   - https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

2. **Enhanced Process Properties** (v20.x)
   - `spawnargs: Array<string>` - Full command-line arguments used to launch the process
   - `spawnfile: string` - Executable file name of the child process
   - `signalCode: string | null` - Signal that terminated the child process
   - https://nodejs.org/api/child_process.html#subprocessspawnargs

**ChildProcess Class Updates:**

3. **Improved Property Types**
   - `stdio` is now a properly typed tuple array with readonly modifier
   - `channel` changed from `Object` to `mixed` for better type safety

4. **Enhanced Method Signatures**
   - `kill(signal?: string | number): boolean` - Now returns boolean and accepts numeric signals
   - `send()` overloads properly typed with `child_process$Serializable` messages
   - `send()` accepts `keepOpen` option: `Readonly<{keepOpen?: boolean}>`
   - https://nodejs.org/api/child_process.html#subprocesskillsignal

**Option Type Improvements:**

6. **Modern Readonly Syntax** - All input options use `Readonly<{...}>`
   - `execOpts`, `execFileOpts`, `forkOpts`, `spawnOpts`, `spawnSyncOpts`, etc.
   - Allows passing readonly types safely

7. **Enhanced Environment Variables**
   - Changed `env?: Object` to `env?: {[key: string]: string | void}`
   - More precise typing for environment variable dictionaries

8. **New Fork Options** (IPC enhancements)
   - `serialization?: 'json' | 'advanced'` - IPC serialization format
   - `killSignal` and `timeout` options added to fork
   - https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options

9. **Enhanced Spawn Options**
   - Added `killSignal`, `timeout`, `serialization` to `spawnOpts`
   - Better consistency across all spawn functions

**Return Type Fixes:**

10. **spawnRet/spawnSyncRet** - Made fields properly nullable:
    - `status: number | null` - null if process never exited
    - `signal: string | null` - null if not terminated by signal
    - `error: Error | void` - void if no error occurred
    - Removed spread operator for exact types

**Helper Types:**

11. **`child_process$Serializable`** - Union type for IPC messages:
    - `string | number | boolean | bigint | {...} | Array<mixed>`
    - Used in send() method signatures

12. **`child_process$SendHandle`** - Type for handle passing:
    - `net$Server | net$Socket`
    - Used for passing server/socket handles to child processes

**References:**
- Node.js child_process module docs: https://nodejs.org/api/child_process.html
- AbortSignal integration: https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback

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: D89944331

fbshipit-source-id: 744ae04051c2214d97269c48c115060f5f30fb1f
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants