napi_get_property_names: throws on JavaScriptCore; inconsistent enumerability/prototype semantics on Chakra and QuickJS
Los mantenedores suelen responder en 1 día
@bkaradzic-microsoft ya está trabajando en esto.
Desde el 30/7/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
napi_get_property_names behaves differently on all three non-V8 backends, and throws unconditionally on JavaScriptCore. Since Napi::Object::GetPropertyNames() is a direct wrapper, that method is unusable on JSC for every N-API caller — and JSC is the default engine on macOS and iOS.
Reference behaviour (V8)
js_native_api_v8.cc matches the Node-API specification: enumerable, string-keyed properties, including the prototype chain.
obj->GetPropertyNames(
context,
v8::KeyCollectionMode::kIncludePrototypes,
static_cast<v8::PropertyFilter>(
v8::PropertyFilter::ONLY_ENUMERABLE |
v8::PropertyFilter::SKIP_SYMBOLS),
v8::IndexFilter::kIncludeIndices,
v8::KeyConversionMode::kConvertToString);
JavaScriptCore — throws
Core/Node-API/Source/js_native_api_javascriptcore.cc:
CHECK_NAPI(napi_get_named_property(env, object_ctor, "getOwnPropertyNames", &function));
CHECK_NAPI(napi_call_function(env, object_ctor, function, 0, nullptr, result));
The object parameter is never used. The call passes argc 0 / argv nullptr, so it evaluates Object.getOwnPropertyNames(undefined), which throws TypeError. Note there is also no CHECK_ARG(env, object).
Passing the object is necessary but not sufficient. Object.getOwnPropertyNames is own-only and includes non-enumerable properties, so it disagrees with V8 on both axes. A conforming JSC implementation needs enumerable properties across the prototype chain — the semantics of for...in filtered to string keys.
Chakra — own-only, includes non-enumerables
js_native_api_chakra.cc uses JsGetOwnPropertyNames, which is own-only and does not filter to enumerable properties. Wrong on both axes, though it does not throw.
QuickJS — own-only
js_native_api_quickjs.cc uses JS_GetOwnPropertyNames with JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY. Enumerability is correct; the prototype chain is missing.
Summary
| backend | enumerable-only | includes prototype chain | throws |
|---|---|---|---|
| V8 | yes | yes | no |
| JavaScriptCore | n/a | n/a | yes |
| Chakra | no | no | no |
| QuickJS | yes | no | no |
Repro
const proto = { inherited: 1 };
const obj = Object.create(proto);
obj.own = 2;
Object.defineProperty(obj, "hidden", { value: 3, enumerable: false });
// napi_get_property_names(obj) should yield exactly ["own", "inherited"].
On JSC this throws instead of returning. On Chakra it yields ["own", "hidden"]. On QuickJS it yields ["own"].
Impact / workaround
Encountered in Babylon Native while enumerating a plain JS data object (BabylonJS/BabylonNative#1797). The workaround is to fetch Object.keys from the global and call it via napi_call_function, which behaves consistently across engines for plain data objects:
const auto objectCtor = env.Global().Get("Object").As<Napi::Object>();
const auto keys = objectCtor.Get("keys").As<Napi::Function>();
That is only equivalent for own-enumerable cases, so it is a local workaround rather than a fix.
- Lenguaje dominante
- C++
- Estrellas
- 22
- Forks
- 23
- Merge medio
- 2 h 29 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de BabylonJS/JsRuntimeHost
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
BabylonJS/JsRuntimeHost#234 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
BabylonJS/JsRuntimeHost#173 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
BabylonJS/JsRuntimeHost#241 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
BabylonJS/JsRuntimeHost#228 ·
Los mantenedores suelen responder en 1 día
-
napi_unwrap does not reject objects that were never wrapped (V8 port faults, QuickJS port confuses types)Posiblemente ocupada @bghgary la tomó hace 47 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
BabylonJS/JsRuntimeHost#226 ·
Los mantenedores suelen responder en 1 día
Todos los issues de BabylonJS/JsRuntimeHost
Issues similares
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
flashinfer-ai/flashinfer#6212 ·
Los mantenedores suelen responder en 1 día
-
bug graphics
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
FlaxEngine/FlaxEngine#4295 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Algorithmiq/monoprop#390 ·
Los mantenedores suelen responder en 1 día
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
leethomason/tinyxml2#1097 ·