Skip to content

Bug related to using Object.__proto__ within async call? #54930

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

Closed
tizmagik opened this issue Sep 13, 2024 · 7 comments
Closed

Bug related to using Object.__proto__ within async call? #54930

tizmagik opened this issue Sep 13, 2024 · 7 comments
Labels
promises Issues and PRs related to ECMAScript promises. v8 engine Issues and PRs related to the V8 dependency.

Comments

@tizmagik
Copy link

Version

v22.8.0

Platform

Darwin MacBook-Pro-103.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6030 arm64

Subsystem

No response

What steps will reproduce the bug?

Using Object.__proto__ inside async call.

See minimal reproduction repo: https://github.com./tizmagik/async-object-proto-repro

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

Every time

What is the expected behavior? Why is that the expected behavior?

Should behave similarly to sync call

What do you see instead?

Async thread appears to exit early or crash, although no visible output

Additional information

https://github.com./tizmagik/async-object-proto-repro

@tizmagik
Copy link
Author

I also posted this to Chromium v8 tracker -- sorry I'm not sure exactly where is the correct place to report this: https://partnerissuetracker.corp.google.com/issues/366268202

@avivkeller
Copy link
Member

I also posted this to Chromium v8 tracker -- sorry I'm not sure exactly where is the correct place to report this: https://partnerissuetracker.corp.google.com/issues/366268202

👋 did you happen to report it in an internal tracker? It doesn’t seem like that is accessible from non-google.com emails.

@avivkeller
Copy link
Member

avivkeller commented Sep 13, 2024

Repro:

console.log("BEFORE");
await new Promise((resolve, reject) =>
  resolve({ __proto__: new Proxy({}, { get: () => () => {} }) })
);
console.log("AFTER");

@nodejs/loaders when running the file using typeless module detection, the program silently exists.

However, when running the file from a .mjs file, the following is shown:

Warning: Detected unsettled top-level await at file:///repro.mjs:2

That behavior is being tracked at #54931


The issue isn't with the Proxy, it's with the promise. Take a look at the following repro:

await { then() {} };

This won't execute successfully.

The proxy is returning a function for the then value, so it's throwing the same error as the code above would.

@avivkeller avivkeller added promises Issues and PRs related to ECMAScript promises. v8 engine Issues and PRs related to the V8 dependency. labels Sep 13, 2024
@avivkeller
Copy link
Member

avivkeller commented Sep 13, 2024

Chromium displays the same behavior:

await { then() {} }; console.log('after');

'after' will never be logged.

@ljharb
Copy link
Member

ljharb commented Sep 13, 2024

I think the issue is that you've made an object whose [[Prototype]] is a Proxy (not Object.__proto__, and that phrasing may be confusing to many)

@avivkeller
Copy link
Member

I think the issue is that you've made an object whose [[Prototype]] is a Proxy (not Object.__proto__, and that phrasing may be confusing to many)

From what I can tell, the proxy prototype is working as expected, it just crashes when it tries to get the then value

@aduh95
Copy link
Contributor

aduh95 commented Sep 14, 2024

Object.__proto__ is not used at all in the repro (at least in #54930 (comment)). But anyway, what would you expect to happen? If the promise never resolves, the code after the await is never run, that's definitely aligned with the spec. It's the exact same behavior as await new Proxy({}, { get: () => () => {} }), or await new Promise(() => {}), or await { then() {} }.

Closing as Working as expected, let me know if I missed something.

@aduh95 aduh95 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
promises Issues and PRs related to ECMAScript promises. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

4 participants