Skip to content
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

fix(ext/node): support stdin child_process IPC & fd stdout/stderr #24106

Merged
merged 8 commits into from
Jun 7, 2024

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Jun 5, 2024

Add supports for "ipc" and fd options in child_process spawn API.

Internal changes: Adds a hidden rid and "ipc_for_internal_use" option to Deno.Command. Used by node:child_process

Example:

const out = fs.openSync("./logfile.txt", 'a')
const proc = spawn(process.execPath, ["./main.mjs", "child"], {
  stdio: ["ipc", out, "inherit"]
});

Ref #16753

@littledivy littledivy changed the title fix(ext/node): support stdin child_process IPC fix(ext/node): support stdin child_process IPC & fd stdout/stderr Jun 5, 2024
Co-authored-by: Satya Rohith <[email protected]>
Signed-off-by: Divy Srivastava <[email protected]>
Copy link
Member

@satyarohith satyarohith left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, nice work. Can you confirm that this change makes pm2 work properly before landing?

@littledivy
Copy link
Member Author

@bartlomieju there is another error before pm2 works:

error: Uncaught TypeError: Cannot read properties of undefined (reading 'unref')
    at ChildProcess.unref (ext:deno_node/internal/child_process.ts:221:19)
    at module.exports.Client.launchDaemon (file:https:///home/divy/.cache/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:274:9)
    at file:https:///home/divy/.cache/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:104:10
    at file:https:///home/divy/.cache/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:321:14
    at Array.processTicksAndRejections (ext:deno_node/_next_tick.ts:25:11)
    at eventLoopTick (ext:core/01_core.js:166:29)

This should be an easy one, will fix in a follow up

@littledivy littledivy merged commit 3735a1a into denoland:main Jun 7, 2024
17 checks passed
@littledivy littledivy deleted the pm2_ipc branch June 7, 2024 17:21
nathanwhit pushed a commit that referenced this pull request Jun 13, 2024
…4106)

Add supports for "ipc" and fd options in child_process spawn API.

Internal changes: Adds a hidden rid and "ipc_for_internal_use" option to
Deno.Command. Used by `node:child_process`

Example:
```js
const out = fs.openSync("./logfile.txt", 'a')
const proc = spawn(process.execPath, ["./main.mjs", "child"], {
  stdio: ["ipc", out, "inherit"]
});
```

Ref #16753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants