Files
bun.sh/test/napi
Dylan Conway 1a8a5cd883 fix(napi): allow structuredClone on napi_create_object results
Bun's napi_create_object creates a NapiPrototype (JSDestructibleObject subclass)
instead of a plain JSFinalObject. The NapiPrototype has an inline napiRef field
as a fast path for napi_wrap/unwrap.

WebKit's SerializedScriptValue serializer checks classInfo() != JSFinalObject::info()
before treating an object as a generic clonable object. NapiPrototype has its own
ClassInfo, so the check failed with DataCloneError.

This adds NapiPrototype::info() to the serializer's allowlist. The inline napiRef
C++ field is invisible to property enumeration (serializer uses getOwnPropertyNames
with PrivateSymbolMode::Exclude), so cloned objects correctly get only the JS
properties — matching Node.js behavior where napi_unwrap also fails on cloned objects.

Fixes #25658
2026-02-25 20:21:44 -08:00
..