Expose process.env.NODE_OPTIONS
parser to user land
#52709
Labels
c++
Issues and PRs that require attention from people who are familiar with C++.
feature request
Issues that request new features to be added to Node.js.
lib / src
Issues and PRs related to general changes in the lib or src directory.
stale
util
Issues and PRs related to the built-in util module.
What is the problem this feature will solve?
Node.js has an internal parser for correctly parsing and validating the
process.env.NODE_OPTIONS
variable. I'd like to expose this parser to user land as something likeutil.parseNodeOptions
.What is the feature you are proposing to solve the problem?
The exact parser code is here:
node/src/node_options.cc
Line 1401 in c29d53c
The solution should create a new C++ function that accesses the
NODE_OPTIONS
environment variable from theEnvironment
so that we do not incur an unnecessary serialization cost passing theNODE_OPTIONS
from JS.Calling the function should return the list of strings.
The function should throw any error it encounters during the parsing process.
I will contribute this feature myself soon 👍
What alternatives have you considered?
We required this functionality for a recent bug in Next.js. I was able to solve that issue by manually converting the C++ parser to JS and using that.
The PR introducing the fix: vercel/next.js#65046
The JS parser implementation itself: https://github.com/vercel/next.js/blob/270a9db0567808db5d53e7a18c7be0a4710796e8/packages/next/src/server/lib/utils.ts#L59-L113
The text was updated successfully, but these errors were encountered: