Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
repl: limit line processing to one at a time#39392
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Conversation
ejose19 commented Jul 15, 2021
@guybedford Feel free to take a look at this |
Uh oh!
There was an error while loading. Please reload this page.
guybedford left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please clarify if any of the changes here are major / breaking changes?
//cc @nodejs/repl for more reviewers.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ejose19 commented Jul 15, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I'd like to add the output of |
guybedford commented Jul 15, 2021
@ejose19 I'm not aware of any debug stream testing, but there might be some examples in the existing tests directory to be found. Alternatively setting up something custom could be worthwhile unless someone else can clarify further here. |
ejose19 commented Jul 15, 2021
@guybedford I had to replace the original |
guybedford commented Jul 15, 2021
@ejose19 if we're doing a major change here anyway, should we also support |
ejose19 commented Jul 16, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@guybedford That would require a major overhaul in the tests, since most of them expect the output right after writing the input, which is the case for sync code. But if So even if using async |
guybedford commented Jul 16, 2021
@ejose19 what I mean is branching the API on sync / async handling with: eval: ()=>Promise|undefinedwhere the undefined case is treated as sync, and the promise case is treated as the async situation, for example rather than enforcing the callback. That's not the exact approach but along those lines I mean. |
ejose19 commented Jul 16, 2021
@guybedford you mean something like this? constevalResult=self.eval(evalCmd,self.context,getREPLResourceName(),finish);if(evalResult!==undefined){if(!(evalResultinstanceofPromise)){self._domain.emit('error','eval must return "undefined" or a "Promise"');return;}(async()=>{const{ error, result }=awaitevalResult;finish(error,result);})();} |
guybedford commented Jul 16, 2021
Yes that seems like the sort of approach if you agree it could make sense. Would this also allow this PR to be done in a backwards compatible way perhaps? Perhaps we should consider being more lenient on the return value to be safe in that case? Either way wrt the validation could work for me though. |
ejose19 commented Jul 16, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I don't think it can be made backward compatible, we can't assume Lines 606 to 623 in 44e3822
If other projects based their Ideally, |
guybedford commented Jul 16, 2021
@ejose19 I guess I'm still not clear on how the callback can be optional currently. But if the current eval doesn't return a value, then allowing the current eval to return a promise would be a backwards-compatible extension. Then allowing that promise to be a completion based callback that fits the requirements you needed for the async callback could also be a way to possible shoehorn this feature in a backwards compatible way (separate to the explicit callback mechanism). Again I'm not super clear on the details of this code, so fill me in where I'm wrong :) |
ejose19 commented Jul 16, 2021
@guybedford If something like this is added to the PR, then
For any code that is not returning a So what I mean is, while we can improve the "handling" of |
guybedford commented Jul 16, 2021
So because the invariant of per-line processing requires all eval implementations to conform, there's no middle ground here on creating a backwards compatible subset, got it. In that case moving ahead with this as-is seems fine to me. |
guybedford commented Jul 16, 2021
One other question - what will be the outcome for eval implementations that do not call the callback? Will it just stall? |
ejose19 commented Jul 16, 2021
Correct, for most commands that will be the outcome, unless other event resets the |
guybedford commented Jul 16, 2021
@ejose19 another option could be to check the function length of the |
ejose19 commented Jul 16, 2021
@guybedford Ok, that's an interesting approach, but it's enough for this to be considered non breaking? What about consumers that defined the argument but never called it? |
ejose19 commented Jul 16, 2021
I tried with that, and it seems this line: Line 632 in 44e3822
makes the function to have a different length than the original (0 vs 4 for |
guybedford commented Jul 16, 2021
Ok, thanks for hearing me out on these questions, agreed the major is best then with the callback being enforced. |
Co-authored-by: Antoine du Hamel <[email protected]>
nodejs-github-bot commented Nov 24, 2021
nodejs-github-bot commented Dec 19, 2021
jasnell commented Dec 24, 2021
The CI failures here need to be investigated. They appear they might b relevant to the change |
Fixes: #39387