Skip to content

src: add function to reset arguments to default #22192

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

Closed
wants to merge 2 commits into from

Conversation

Let0s
Copy link

@Let0s Let0s commented Aug 8, 2018

Embedder can initialize nodejs to run scripts few times with different
arguments. But if arguments from old launch weren't restored to theirs
default values, nodejs can launch wrong next time.

This function allows to reset arguments, which was impossible
for embedder without modifying nodejs source code.

Fixes: #21653

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • 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 Aug 8, 2018
@addaleax
Copy link
Member

addaleax commented Aug 8, 2018

The big issue here is that this is more of a band-aid than a real solution – most of these options shouldn’t actually be global state. So while we can land this, we should probably mark it very clearly as an API that is going to be removed or broken as soon as we can do so…

@addaleax addaleax added semver-minor PRs that contain new features and should be released in the next minor version. embedding Issues and PRs related to embedding Node.js in another project. labels Aug 8, 2018
@Let0s
Copy link
Author

Let0s commented Aug 8, 2018

@addaleax, OK. Then, I think, it may be good to move options to Environment class. Also some global functions should be moved to Environment (Init, ParseArgs, SetupProcessObject and so on). Then every Environment will have its own launch arguments, and will have default options after creating. What do you think about it?

@jasnell
Copy link
Member

jasnell commented Aug 8, 2018

I tried making some improvements to this before and ran into some roadblocks. Can give it another try. Like @addaleax, I'm thinking the approach taken in this PR is more of a bandaid quick fix.

@addaleax
Copy link
Member

addaleax commented Aug 8, 2018

@Let0s The thing is, some options are global (per-process), some are per-Isolate, some are per-Environment. I can probably help with triaging them into the different categories, but … it’s not obvious how to best implement the result.

@addaleax
Copy link
Member

addaleax commented Aug 9, 2018

@Let0s I’ll take another stab at refactoring some of our options code tomorrow and let you know how that goes. :)

@BridgeAR
Copy link
Member

BridgeAR commented Sep 5, 2018

@addaleax since you refactored a lot of the options recently: is this resolved with that as well?

@addaleax
Copy link
Member

addaleax commented Sep 5, 2018

No, but it’s easier to do properly now… I can try to get to it within the next days.

@jasnell
Copy link
Member

jasnell commented Sep 5, 2018

This needs a rebase

@empyrical
Copy link

@Let0s Could you provide a minimal example that reproduces this? Would like to make a unit test and try and fix this

@Let0s
Copy link
Author

Let0s commented Oct 5, 2018

@empyrical I can't write example now, but idea is following:

  1. Init and run nodejs with eval arguments (e.g. node -e "console.log(123)").
  2. Then Init and run (in the same process) nodejs with launch-from-file arguments (e.g. node filename.js). File content sample: console.log('hello').
    In this case first log message will be shown, and second - won't, but it must be shown.
    If this info is not enough, I'll try to write sample app within a few days, which will reproduce this issue

@empyrical
Copy link

Oh, I get it now. Thanks!

@jasnell
Copy link
Member

jasnell commented Oct 6, 2018

This needs a rebase now!

@addaleax addaleax added the wip Issues and PRs that are still a work in progress. label Oct 6, 2018
@addaleax
Copy link
Member

addaleax commented Oct 6, 2018

@jasnell I’m labelling this in progress because it targets the older version of our options parser, and the API needs some work as well. (i.e. there’s a lot more to do than rebasing)

@Let0s
Copy link
Author

Let0s commented Oct 10, 2018

@addaleax I saw changes and I don't think if my PR is still useful. Only if make function, that will reset options, for each options class. Or maybe it will be better to re-create per_process_opts variable.

Let0s added 2 commits October 16, 2018 16:39
Embedder can initialize nodejs to run scripts few times with different
arguments. But if arguments from old launch weren't restored to theirs
default values, nodejs can launch wrong next time.

This function allows to reset arguments, which was impossible
for embedder without modifying nodejs source code.

Fixes: nodejs#21653
@Let0s Let0s force-pushed the reset-arguments-to-default branch from 62ceb16 to 70919ae Compare October 17, 2018 07:20
@BridgeAR
Copy link
Member

This seems to be outdated and if I understand the comments above is not necessary anymore. Thus, I close this.

@Let0s thanks a lot for your contribution nevertheless! If I closed this by mistake, please just open a new PR or leave a comment.

@BridgeAR BridgeAR closed this Mar 10, 2019
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++. embedding Issues and PRs related to embedding Node.js in another project. semver-minor PRs that contain new features and should be released in the next minor version. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants