Skip to content

Async function execute in different version got different output about async function itself #1733

Closed

Description

@Jiasm
  • Node.js Version: 11.7.0 & 10.15.0
  • OS: macOS
  • Scope (install, code, runtime, meta, other?): runtime

I found an interesting things,
Simple test code:

async function test () {
  await 1
}

console.log(test.constructor.name, test.prototype)

test()

console.log(test.constructor.name, test.prototype)

When I use the 10.15.0 version, I got two different outputs.
This does not appear on the 11.7.0 version.

image

I did not find the relevant modification record on the ChangeLog.
I'm not sure if it is a bug fix, or an implementation change. Can you provide the corresponding information?
I'm more interested in this, thank you.

Activity

  1. vsemozhetbyt commented on Jan 23, 2019

    @vsemozhetbyt

    On Windows 7 x64:

    >node.08.15.0.v8-6.2.exe test.js
    AsyncFunction undefined
    AsyncFunction {}
    
    >node.10.15.0.v8-6.8.exe test.js
    AsyncFunction undefined
    AsyncFunction Object [Generator] {}
    
    >node.11.7.0.v8-7.0.exe test.js
    AsyncFunction undefined
    AsyncFunction undefined
    
  2. vsemozhetbyt commented on Jan 23, 2019

    @vsemozhetbyt

    cc @nodejs/v8

  3. Hakerh400 commented on Jan 25, 2019

    @Hakerh400

    Seems like it was a bug in old V8.

    async function test(){await 1}
    test()
    console.log('prototype' in test)    // false
    console.log(test.prototype)         // Object [Generator] {}
    console.log(test['prototype'])      // Object [Generator] {}
    console.log(test['prototype' + '']) // undefined

    There's no semantical difference between the last two lines, but they give different results.

  4. yathamravali commented on Jan 31, 2019

    @yathamravali

    I did bisect and landed with this PR:
    nodejs/node#22390
    I'm not sure whether this is a bug or Enhancement. Copying the author to get more insight.
    cc @TimothyGu

  5. TimothyGu commented on Jan 31, 2019

    @TimothyGu
    Member

    @yathamravali The referenced PR was later reverted: nodejs/node#22911. So it couldn’t have been that.

  6. TimothyGu commented on Jan 31, 2019

    @TimothyGu
    Member

    @Hakerh400’s analysis seems correct though.

  7. gireeshpunathil commented on Jun 18, 2019

    @gireeshpunathil
    Member

    closing as answered, let me know if there is anything outstanding here

  8. Hakerh400 commented on Jul 26, 2019

    @Hakerh400

    I did more research on this. This bisects to nodejs/node@0e7ddbd (brought by PR nodejs/node#22754). Further bisecting V8 revealed that the bug is fixed in v8/v8@4ef4dea, as a special case of v8/v8#5085. The relevant test, which is basically the same script from the OP, that was added in that commit is test-regress-5085.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions