Skip to content

Test combining node flags with ts-node entrypoint and flags in process.execArgv #1657

Description

@cspotcode

Pretty sure we have a bug in our execArgv logic. It works only if there are not any other node flags in the execArgv array.

Impact for users:

This affects child_process.fork(), since it uses execArgv to create a similar child runtime.
For example, child_process.fork() fails if node is launched node --no-warnings ./node_modules/ts-node/dist/bin ./index.ts
With the fix, child_process.fork() will automatically preserve node flags and ts-node hooks


To test, create a script that spawns a child that spawns a grandchild. In the grandchild, inspect process.execArgv and process.argv

Run it like this:

node --no-warnings ./dist/bin.js --cwd-mode ./spawner.js

--no-warnings can be any node flag that is not understood by ts-node. --cwd-mode can be any ts-node flag that is not understood by node.

The bug is that we're prepending our modifications to the execArgv array; we should be appending them instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions