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 function execute in different version got different output about async function itself #1733

Closed
Jiasm opened this issue Jan 23, 2019 · 8 comments

Comments

@Jiasm
Copy link

Jiasm commented Jan 23, 2019

  • 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.

@vsemozhetbyt
Copy link

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

@vsemozhetbyt
Copy link

cc @nodejs/v8

@Hakerh400
Copy link

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.

@yathamravali
Copy link

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

@TimothyGu
Copy link
Member

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

@TimothyGu
Copy link
Member

@Hakerh400’s analysis seems correct though.

@gireeshpunathil
Copy link
Member

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

@Hakerh400
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants