Skip to content

Top-level await incorrectly awaits promise continuation in REPL #43777

Closed
@tniessen

Description

@tniessen

Version

18.5.0

Platform

Linux 5.13.0-Ubuntu x86_64 x86_64 x86_64 GNU/Linux

Subsystem

repl

What steps will reproduce the bug?

In REPL:

const foo = async () => 123;

foo();

await foo();

typeof (await Promise.resolve(foo))();

(await Promise.resolve(foo))();

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

> const foo = async () => 123;
undefined
> foo();
Promise {
  123,
  [Symbol(async_id_symbol)]: 33,
  [Symbol(trigger_async_id_symbol)]: 5
}
> await foo();
123
> typeof (await Promise.resolve(foo))();
'object'
> (await Promise.resolve(foo))();
Promise {
  123,
  [Symbol(async_id_symbol)]: 108,
  [Symbol(trigger_async_id_symbol)]: 5
}

Note that typeof prints 'object', which is correct and matches Promise { ... }.

What do you see instead?

> const foo = async () => 123;
undefined
> foo();
Promise {
  123,
  [Symbol(async_id_symbol)]: 33,
  [Symbol(trigger_async_id_symbol)]: 5
}
> await foo();
123
> typeof (await Promise.resolve(foo))();
'object'
> (await Promise.resolve(foo))();
123

Note that typeof prints 'object', which is correct, but the value of the expression is shown to be 123 in the REPL, which is a 'number'.

Additional information

Chrome and Edge seem to handle this as I'd expect. Firefox seems to handle this like Node.js (so I'm assuming it's a bug).

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.promisesIssues and PRs related to ECMAScript promises.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