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

Async output in repl is showing after the prompt #35895

Closed
vsemozhetbyt opened this issue Oct 31, 2020 · 5 comments
Closed

Async output in repl is showing after the prompt #35895

vsemozhetbyt opened this issue Oct 31, 2020 · 5 comments
Labels
repl Issues and PRs related to the REPL subsystem.

Comments

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Oct 31, 2020

  • Version: 14.15.0, 15.0.1
  • Platform: Windows 10 x64
  • Subsystem: repl
> throw new Error();
Uncaught Error
> // prompt is shown
> new Promise((rs, rj) => { rj(); })
Promise { <rejected> undefined }
> (node:4108) UnhandledPromiseRejectionWarning: undefined
(node:4108) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)
// no NEW prompt 
> new Promise((rs, rj) => { rj(); }).catch(console.log)
Promise { <pending> }
> undefined
// no NEW prompt 
> new Promise((rs, rj) => { rj(); }).catch(()=>{})
Promise { <pending> }
> // prompt is shown
> new Promise((rs, rj) => { rs(42); }).then(console.log)
Promise { <pending> }
> 42
// no NEW prompt here
@vsemozhetbyt vsemozhetbyt changed the title Rejected promise prevents repl from showing prompt if somithing is logged before Async output in repl is showing after the prompt Oct 31, 2020
@PoojaDurgad PoojaDurgad added the repl Issues and PRs related to the REPL subsystem. label Dec 18, 2020
@antsmartian
Copy link
Contributor

Ok i'm testing the scenario from master now. The scenario mentioned:

> new Promise((rs, rj) => { rj(); })
Promise { <rejected> undefined }
> (node:4108) UnhandledPromiseRejectionWarning: undefined
(node:4108) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)
// no NEW prompt 

is now crashing the repl altogether.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Mar 17, 2021

When I try it in 15.11.0 or in today's nightly or canary, I get the same output, now it seems OK:

> new Promise((rs, rj) => { rj(); })
Promise { <rejected> undefined }
> Uncaught undefined
> // Prompt is here!

@antsmartian
Copy link
Contributor

@vsemozhetbyt Yes the other issues still seems to be present.

@BridgeAR
Copy link
Member

The reason the Uncaught part now works is that it does not cause a deprecation warning anymore due to the specified unhandled rejection warning.

It is tricky to fix this, since we write on the stream directly. We do not use the regular input methods for e.g., warnings. And what should happen for async writes on the stream? Should they be marked specially? It is currently intermixed with the line input and visualized as input. That's incorrect but difficult to fix, especially in a way that is easy to understand for users.

@RedYetiDev RedYetiDev mentioned this issue Jun 24, 2024
3 tasks
@StefanStojanovic
Copy link
Contributor

This issue has been stale for a long time. Also, it focuses on an old, no longer supported version of Node. I'll close it for those reasons. If needed, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants