mirror of
https://github.com/oven-sh/bun
synced 2026-02-28 12:31:00 +01:00
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