Open antocuni opened 1 year ago
Consider the following example:
// worker.js importScripts("./iife/synclink.js"); function raiseFromWorker(){ const err = new Error("hi!"); err.xxx = 42; throw err; } Synclink.expose(raiseFromWorker);
<!-- index.html > <html> <head> <script> async function main() { const Synclink = await import("./esm/synclink.mjs"); let raiseFromWorker = Synclink.wrap(new Worker("worker.js")) try { await raiseFromWorker(); } catch(err) { //console.log(err); console.log(err.message); console.log(err.xxx); } } main(); </script> </head> </html>
The attribute xxx is not preserved across the boundary. I think it would be nice/useful/expected that it is. For example, this would remove the need for this ugly hack in pyscript: https://github.com/pyscript/pyscript/blob/b247864414ae813b6ff73792d10a344bc4d477f9/pyscriptjs/src/main.ts#L30-L41
xxx
If I understand correctly, the relevant code is here: https://github.com/hoodmane/synclink/blob/cc08aab7d28f5b5573c80a3766714944bf666160/src/transfer_handlers.ts#L156-L164
would it be possible to iterate over all attributes and transfer them?
Yes, this should be a simple patch.
Consider the following example:
The attribute
xxx
is not preserved across the boundary. I think it would be nice/useful/expected that it is. For example, this would remove the need for this ugly hack in pyscript: https://github.com/pyscript/pyscript/blob/b247864414ae813b6ff73792d10a344bc4d477f9/pyscriptjs/src/main.ts#L30-L41If I understand correctly, the relevant code is here: https://github.com/hoodmane/synclink/blob/cc08aab7d28f5b5573c80a3766714944bf666160/src/transfer_handlers.ts#L156-L164
would it be possible to iterate over all attributes and transfer them?