denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.91k stars 5.22k forks source link

1.45.3 breaks `self` descriptor #24683

Closed zloirock closed 2 weeks ago

zloirock commented 1 month ago

globalThis.self should be a getter, but 1.45.3 breaks it - here it's a usual property:

Снимок экрана 2024-07-23 в 09 11 13

Before that:

Снимок экрана 2024-07-23 в 09 45 01

That enforces core-js to load a polyfill and patch it.

nathanwhit commented 1 month ago

Looks like this regressed in 76b8ecbb6d8c07d29c34fb0b301cc3bf3351e3aa (cc @kt3k).

kt3k commented 1 month ago

Looks like the global var segregator (interceptor) in ext/node/global.rs doesn't transfer(?) property descriptor correctly from inner object at Object.getOwnPropertyDescriptor call.

The same issue seems happening to window, which is defined as getter-only property in runtime/js/98_global_scope_window.js, but Object.getOwnPropertyDescriptor(globalThis, "window") returns:

{
  value: Window {},
  writable: true,
  enumerable: true,
  configurable: true
}

@lucacasonato Do you have any clue on this?

kt3k commented 1 month ago

Some notes:

It looks strange that getter callback is called at Object.getOwnPropertyDescriptor call, but one solution (workaround) might be returning v8::Intercepted::No in getter intercepter for key self (and window).

devsnek commented 1 month ago

This is a bug in V8, caused by assuming that an object can only have one ACCESS_CHECK, and therefore never reaching the INTERCEPTOR state for the global object: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-objects.cc;l=1834;drc=2017cd8a8925f180257662f78eaf9eb93e8e394d?q=js-objects.cc&ss=chromium I have submitted a patch here: https://chromium-review.googlesource.com/c/v8/v8/+/5737946

zloirock commented 2 weeks ago

It seems it's fixed in 1.46.0.