Sandbox: Exclude transferable objects from near membrane proxy unboxing (#115016)

* Fixing so geomap works with sandbox

* Will not try to unbox transferable instances.
This commit is contained in:
Marcus Andersson
2025-12-15 15:15:08 +01:00
committed by GitHub
parent 12dd3dffe0
commit 9ceff992aa
@@ -78,11 +78,36 @@ export function unboxNearMembraneProxies(structure: unknown): unknown {
if (Array.isArray(structure)) {
return structure.map(unboxNearMembraneProxies);
}
if (isTransferable(structure)) {
return structure;
}
if (typeof structure === 'object') {
return Object.keys(structure).reduce((acc, key) => {
Reflect.set(acc, key, unboxNearMembraneProxies(Reflect.get(structure, key)));
return acc;
}, {});
}
return structure;
}
function isTransferable(structure: unknown): structure is Transferable {
// We should probably add all of the transferable types here.
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects
return (
structure instanceof ArrayBuffer ||
structure instanceof OffscreenCanvas ||
structure instanceof ImageBitmap ||
structure instanceof MessagePort ||
structure instanceof MediaSourceHandle ||
structure instanceof ReadableStream ||
structure instanceof WritableStream ||
structure instanceof TransformStream ||
structure instanceof AudioData ||
structure instanceof VideoFrame ||
structure instanceof RTCDataChannel ||
structure instanceof ArrayBuffer
);
}