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

feat(node): add child_process.fork #1695

Merged
merged 10 commits into from
Dec 10, 2021
Merged

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Dec 9, 2021

This PR implements child_process.fork in std/node

This implements at least the basic feature of fork and enabled the basic test cases (child-process-spawn-node.js).

This doesn't implement ipc features. So I commented out ipe-related assertion in the test cases.

The diff might look big, but that is because this PR moves ChildProcess class from node/child_process to node/internal/chil_process to follow the internal structure of Node.js code base.

closes #1690

@kt3k
Copy link
Member Author

kt3k commented Dec 9, 2021

The CI is blocked by #1694

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.

@kt3k is this ready? I don't see any new method in the chil_process.ts file.

@kt3k
Copy link
Member Author

kt3k commented Dec 9, 2021

@bartlomieju This should add fork method. Please see the last line of node/child_process.ts. BTW now we have two child_process.ts files in node/ and node/internal/.

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.

Thanks @kt3k I was looking at the wrong file. This API is gonna be tricky due to flags, but this is good progress

"--compat",
"--unstable",
"--no-check",
"--location=https://example.com",
Copy link
Member

Choose a reason for hiding this comment

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

Why is location argument needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some npm module does something like typeof location to detect the environment and causes uncaught errors. So giving --location avoids those errors, but that probably should be solved by denoland/deno#12969

Ok. I'll remove this option as a first pass

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's address it in Deno directly

"--unstable",
"--no-check",
"--location=https://example.com",
"--allow-all",
Copy link
Member

Choose a reason for hiding this comment

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

Yeah... this is problematic, ideally we'd use the same permissions as the parent process, but unfortunately we don't have access to these flags.

@kt3k
Copy link
Member Author

kt3k commented Dec 9, 2021

Oh, because we use deno run --compat for spawning subcommand, the subprocess have to use [email protected] for std/node and which still includes BINARY notation in enum..

@bartlomieju
Copy link
Member

Unfortunately I don't see a good way to fix it at the moment, as deno.land/std/ doesn't allow to link to main branch

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

Comment on lines +103 to +104
env:
DENO_NODE_COMPAT_URL: file:///${{ github.workspace }}/
Copy link
Member

Choose a reason for hiding this comment

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

This is a good workaround for now

@kt3k kt3k merged commit 05bcd7f into denoland:main Dec 10, 2021
@kt3k kt3k deleted the feat/child_process-fork branch December 10, 2021 05:06
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.

node: add child_process.fork
2 participants