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

process: correctly parse Unicode in NODE_OPTIONS #34476

Closed
wants to merge 5 commits into from

Conversation

bzoz
Copy link
Contributor

@bzoz bzoz commented Jul 22, 2020

Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed
correctly.

Fixes: #34399

Reused the code from node_env_var.cc for getting the enviroment variable value.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jul 22, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Comment on lines 11 to 20
const NODE_OPTIONS = `--redirect-warnings=${expected_redirect_value}`;
const result = cp.spawnSync(process.argv0,
['--expose-internals', __filename, 'test'],
{
env: {
NODE_OPTIONS
}
});
Copy link
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
const NODE_OPTIONS = `--redirect-warnings=${expected_redirect_value}`;
const result = cp.spawnSync(process.argv0,
['--expose-internals', __filename, 'test'],
{
env: {
NODE_OPTIONS
}
});
const env = { NODE_OPTIONS: `--redirect-warnings=${expected_redirect_value}` };
const result = cp.spawnSync(process.argv0,
['--expose-internals', __filename, 'test'],
{ env });

}
});
assert.strictEqual(result.status, 0);
process.exit(0);
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary?


const expected_redirect_value = 'foó';

if (process.argv.length === 2) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd prefer to have explicit check for 'child process' case (i.e. if (process.argv[2] === 'test') {) instead to handle possibly different test start args.


if (process.argv.length === 2) {
const NODE_OPTIONS = `--redirect-warnings=${expected_redirect_value}`;
const result = cp.spawnSync(process.argv0,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const result = cp.spawnSync(process.argv0,
const result = cp.spawnSync(process.execPath,

@nodejs-github-bot
Copy link
Collaborator

@bzoz
Copy link
Contributor Author

bzoz commented Aug 12, 2020

Fixed some nits and rebased.

@nodejs-github-bot
Copy link
Collaborator

@bzoz
Copy link
Contributor Author

bzoz commented Aug 20, 2020

Ok, this is weird. This fails only on ubuntu1804_sharedlibs_openssl111_x64 with this error message:

ot ok 2466 parallel/test-unicode-node-options
  ---
  duration_ms: 0.144
  severity: fail
  exitcode: 1
  stack: |-
    out/Release/node: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1b' not found (required by out/Release/node)
    assert.js:103
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
    
    1 !== 0
    
        at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux-containered/test/parallel/test-unicode-node-options.js:18:10)
        at Module._compile (internal/modules/cjs/loader.js:1089:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1110:10)
        at Module.load (internal/modules/cjs/loader.js:954:32)
        at Function.Module._load (internal/modules/cjs/loader.js:795:14)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
        at internal/main/run_main_module.js:17:47 {
      generatedMessage: true,
      code: 'ERR_ASSERTION',
      actual: 1,
      expected: 0,
      operator: 'strictEqual'
    }
  ...

It looks like other tests can spawn new Node instances just fine. I'm stuck here 🤔

const result = cp.spawnSync(process.argv0,
['--expose-internals', __filename, 'test'],
{
env: { NODE_OPTIONS },
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this help with the current CI failure?

Suggested change
env: { NODE_OPTIONS },
env: { ...process.env, NODE_OPTIONS },

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it helped. Thanks!

@bzoz
Copy link
Contributor Author

bzoz commented Aug 20, 2020

bzoz added a commit to JaneaSystems/node that referenced this pull request Aug 20, 2020
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed
correctly.

Fixes: nodejs#34399

PR-URL: nodejs#34476
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@bzoz
Copy link
Contributor Author

bzoz commented Aug 20, 2020

Green CI, landed in de565ad

@bzoz bzoz closed this Aug 20, 2020
BethGriggs pushed a commit that referenced this pull request Aug 20, 2020
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed
correctly.

Fixes: #34399

PR-URL: #34476
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@danielleadams danielleadams mentioned this pull request Aug 20, 2020
BethGriggs pushed a commit that referenced this pull request Aug 20, 2020
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed
correctly.

Fixes: #34399

PR-URL: #34476
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
addaleax pushed a commit that referenced this pull request Sep 22, 2020
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed
correctly.

Fixes: #34399

PR-URL: #34476
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
addaleax pushed a commit that referenced this pull request Sep 22, 2020
Fixes an issue on Windows, where Unicode in NODE_OPTIONS was not parsed
correctly.

Fixes: #34399

PR-URL: #34476
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
@codebytere codebytere mentioned this pull request Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unicode characters are not properly parsed from NODE_OPTIONS on Windows
7 participants