question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

node: need a way to spawn process.execPath with no deno specific flags

See original GitHub issue

Describe the bug Many Node.js tests spawn the node executable in a child process. This is separate from child_process.fork(). As an example, see this test. The problem in that test is that in Deno’s compat mode, the spawnSync() call needs to be updated to pass in necessary Deno CLI flags (-A, --unstable, etc.).

For users, this is a problem because they can’t run existing Node code as is. For us, it’s also a problem because by modifying the Node tests, we lose the ability to automatically upgrade them to newer versions of Node.

A few ideas on how to approach this:

  • In the compat code, detect when we are spawning the current executable and set an environment variable that allows Deno to start up properly with no CLI flags. This would require changes in core.
  • In the compat code, detect when we are spawning the current executable and add the CLI flags. This could be done in std alone, but might have some edge cases.

Steps to Reproduce

Spawn process.execPath in Node compat mode without changing any of the CLI flags.

Expected behavior

Node compat code runs without modifications.

Environment

  • OS: all
  • deno version: 1.25.3
  • std version: 0.156.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cjihrigcommented, Sep 27, 2022

Discussed this internally today. The plan is to land https://github.com/denoland/deno_std/pull/2688 and begin working on a Node argument parser in Deno. Once that is ready, the mapping logic in #2688 can be ripped back out.

0reactions
lino-levancommented, Oct 30, 2022

Compat mode no longer exists, is this still relevant? #2688 landed a while ago and I haven’t seen a lot of movement on this issue. If there is something to be done, I’d love to pick it up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node/README.md | std@0.129.0
When working with child_process modules, you will have to run tests pulled from Node.js. These tests usually spawn deno child processes via the...
Read more >
Child process | Node.js v19.3.0 Documentation
The child_process. spawn() method spawns the child process asynchronously, without blocking the Node. js event loop. The child_process.
Read more >
How to get path of nodejs executable on runtime
In the example of the official document, it demo the case that process.argv0 is not the node binary. customArgv0 is for exec 's...
Read more >
Top 5 child_process Code Examples
' + `Received type ${typeName(args)}` }); }); } // Test that we can call spawn const child = new ChildProcess(); child.spawn({ file: process.execPath,...
Read more >
How to use execFile function in child_process - Javascript
xit('--title flag (fails on Node v8.x)', async function() { const result = await new ... How to use ... execFile(Showing top 15 results...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found