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

[Bug?]: NODE_OPTIONS in .env file not pulled in correctly #9733

Closed
1 task
cjreimer opened this issue Dec 20, 2023 · 2 comments · Fixed by #9735
Closed
1 task

[Bug?]: NODE_OPTIONS in .env file not pulled in correctly #9733

cjreimer opened this issue Dec 20, 2023 · 2 comments · Fixed by #9735
Labels
bug/confirmed We have confirmed this is a bug topic/cli

Comments

@cjreimer
Copy link
Contributor

What's not working?

The code in redwood is:

export function getDevNodeOptions() {
  const { NODE_OPTIONS } = process.env

  const enableSourceMapsOption = '--enable-source-maps'

  if (!NODE_OPTIONS) {
    return `NODE_OPTIONS=${enableSourceMapsOption}`
  }

  if (NODE_OPTIONS.includes(enableSourceMapsOption)) {
    return NODE_OPTIONS
  }

  return `${NODE_OPTIONS} ${enableSourceMapsOption}`
}

If an .env file with NODE_OPTIONS is provided, we get an error:

api | '--enable-source-maps' is not recognized as an internal or external command,
api | operable program or batch file.
api | node:events:495
api |       throw er; // Unhandled 'error' event
api |       ^

At first glance, it looks to me like NODE_OPTIONS= is not appropriately inserted in front of the combined options.

How do we reproduce the bug?

No response

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • I'm interested in working on this
@cjreimer cjreimer added the bug/needs-info More information is needed for reproduction label Dec 20, 2023
@jtoar jtoar added bug/confirmed We have confirmed this is a bug topic/cli and removed bug/needs-info More information is needed for reproduction labels Dec 20, 2023
jtoar added a commit that referenced this issue Dec 20, 2023
Fixes #9733.

- don't rely on the function `getDevNodeOptions` to return the whole env
var string (`NODE_OPTIONS="..."`); just return the value of
`NODE_OPTIONS`
- fix the quoting issue #9733 was specifically about where the env var
string would be inserted as `NODE_OPTIONS=--inspect
--enable-source-maps` causing spawn to think `--enable-source-maps` was
meant for something else
- fix the test; the mock value for `NODE_OPTIONS` was incorrect
resulting in a false positive
@jtoar
Copy link
Contributor

jtoar commented Dec 20, 2023

Thanks @cjreimer, fixed this one in #9735. We'll get a release out within a day or two.

@cjreimer
Copy link
Contributor Author

Thanks for the quick response @jtoar!

Tobbe pushed a commit that referenced this issue Dec 21, 2023
Fixes #9733.

- don't rely on the function `getDevNodeOptions` to return the whole env
var string (`NODE_OPTIONS="..."`); just return the value of
`NODE_OPTIONS`
- fix the quoting issue #9733 was specifically about where the env var
string would be inserted as `NODE_OPTIONS=--inspect
--enable-source-maps` causing spawn to think `--enable-source-maps` was
meant for something else
- fix the test; the mock value for `NODE_OPTIONS` was incorrect
resulting in a false positive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug topic/cli
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants