Skip to content
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

Closed
ghost opened this issue Jul 27, 2020 · 7 comments
Labels
cli related to cli/ dir declined thank you, but respectfully declined feat new feature (which has been agreed to/accepted)

Comments

@ghost
Copy link

ghost commented Jul 27, 2020

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).

@caspervonb
Copy link
Contributor

See #3557

@ghost
Copy link
Author

ghost commented Jul 27, 2020

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.

@ry
Copy link
Member

ry commented Jul 27, 2020

@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.

@ry ry changed the title Inability to pass complex data to Workers structured clone should not fail silently but throw not implemented Jul 27, 2020
@ghost
Copy link
Author

ghost commented Jul 27, 2020

@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.

@ghost ghost changed the title structured clone should not fail silently but throw not implemented Structured clone should not fail silently, but instead throw a "not-implemented" error Jul 27, 2020
@ghost
Copy link
Author

ghost commented Sep 24, 2020

@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.

@kitsonk kitsonk added cli related to cli/ dir feat new feature (which has been agreed to/accepted) labels Sep 24, 2020
@kitsonk
Copy link
Contributor

kitsonk commented Sep 24, 2020

I don't believe we have done anything with it, but should.

@kitsonk kitsonk self-assigned this Sep 24, 2020
@bartlomieju bartlomieju mentioned this issue Oct 10, 2020
22 tasks
@kitsonk kitsonk added the declined thank you, but respectfully declined label Feb 18, 2021
@kitsonk kitsonk removed their assignment Feb 18, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Feb 18, 2021

Since #3557 is close to being closed (will be for 1.8), going to close this as declined.

@kitsonk kitsonk closed this as completed Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir declined thank you, but respectfully declined feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

No branches or pull requests

3 participants