镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Async output in repl is showing after the prompt #35895

Description

@vsemozhetbyt
  • 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

Activity

  1. changed the title [-]Rejected promise prevents repl from showing prompt if somithing is logged before[/-] [+]Async output in repl is showing after the prompt[/+] on Oct 31, 2020
  2. added
    replIssues and PRs related to the REPL subsystem.
    on Dec 18, 2020
  3. antsmartian commented on Mar 17, 2021

    @antsmartian
    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.

  4. vsemozhetbyt commented on Mar 17, 2021

    @vsemozhetbyt
    ContributorAuthor

    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!
  5. antsmartian commented on Mar 18, 2021

    @antsmartian
    Contributor

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

  6. BridgeAR commented on Apr 10, 2021

    @BridgeAR
    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.

  7. StefanStojanovic commented on Oct 8, 2024

    @StefanStojanovic
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions