Skip to content

node -p resolves promises earlier in Node.js 22 than previous releases #56144

Closed as not planned
@andreas-schwab

Description

@andreas-schwab
EDIT: background from pscript test suite On riscv64 the testsuite of the pscript python modules fails:

=================================== FAILURES ===================================
______________________ TestFunctions.test_async_and_await ______________________

self = <test_parser2.TestFunctions object at 0x7f2d4a4f2e10>

def test_async_and_await(self):
    if sys.version_info < (3, 6):
        return

    foo = py2js('async def foo(): return 42\n\n')
    spam = py2js('async def spam(): print(await foo())\n\n')
    eggs = py2js('async def eggs(): return await foo()\n\n')
    js = foo + spam + eggs

    assert 'Promise' in evaljs(js + 'foo()')
    assert 'Promise' in evaljs(js + 'spam()')
    assert 'Promise' in evaljs(js + 'eggs()')

    assert '42' in evaljs(js + 'spam()')
  assert '42' not in evaljs(js + 'eggs()')

E AssertionError: assert '42' not in 'Promise { 42 }'
E
E '42' is contained here:
E Promise { 42 }
E ? ++

pscript/tests/test_parser2.py:874: AssertionError
=========================== short test summary info ============================
FAILED pscript/tests/test_parser2.py::TestFunctions::test_async_and_await - A...
============= 1 failed, 223 passed, 2 skipped in 670.27s (0:11:10) =============

This is a regression from node21:

$ node22 -p -e 'var foo; foo = async function flx_foo () { return 42; }; var eggs; eggs = async function flx_eggs () { return await foo(); }; eggs()'
Promise { 42 }
$ node21 -p -e 'var foo; foo = async function flx_foo () { return 42; }; var eggs; eggs = async function flx_eggs () { return await foo(); }; eggs()'
Promise { <pending> }

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliIssues and PRs related to the Node.js command line interface.invalidIssues and PRs that are invalid.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions