-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structured clone should not fail silently, but instead throw a "not-implemented" error #6887
Comments
See #3557 |
Oh, should I close this? In the meanwhile, can errors be thrown as requested? Unless the Deno community would for some reason like the implicit conversions. |
@00ff0000red I agree it should throw not implemented. Structured clone is on our radar but I'm afraid it might take a few weeks before we get to it. |
Sounds great! I can understand that it'll take some time, especially when you actually get around to it, but errors will help until then. |
@ry Can we get some info regarding whether or not anyone has set this up to throw in a newer version? I don't have access to a current version of Deno, and can't update for quite a bit of time, but it'd be great if we can close this old issue. |
I don't believe we have done anything with it, but should. |
Since #3557 is close to being closed (will be for 1.8), going to close this as declined. |
When passing data to a "Worker" and logging data on the other end, it appears that Deno's Workers only support primatives, basic objects, and basic arrays. Pass by move is not implemented yet, but besides that, any attempts to pass any of the following data types all either fail, or are implicitly converted: Map, BitInt, Set, Headers, typed arrays, ArrayBuffers... among many more types.
It also appears that Deno is not using the "Structured Cloning Algorithm" used by the browsers, but instead using
JSON.stringify
or something similar, I hope that this is eventually planned on being updated / replaced. This was determined after passing a BigInt to a worker.Browsers are capable of accepting all of those types listed above, and more. In their current condition, it seems like Deno's Workers are in their infancy (which I guess, after all they really are).
If this can't be fixed soon, can passing non-supported types throw an explicit "not-implemented" error? The biggest problem when debugging my code was seeing maps and arraybuffers just turn into
{ }
. Browser JavaScript already throws errors on anything that cannot be passed without loss into a worker (with the exception of objects using symbols as keys, in which case the key - value isn't copied).The text was updated successfully, but these errors were encountered: