-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Error cause underspecified in Structured Clone algorithm #11321
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
Comments
This was attempted in #5749, but we got stuck. At this point the latest plan is for @syg to move structured cloning into the JavaScript specification, so that we stop missing things added to the ECMAScript types. Until that work happens, you can consider the set of properties cloned to be frozen to the set of properties that are in the JS spec as of ~2020. (So, Chromium and Firefox are actually not conformant to the current spec, which does not allow copying |
* see whatwg/html#11321 Also added limitations in the README to explain that currently the logic is kept minimal and as simple as possible to cover most common/desired use cases without compromising too much performance (via overly crawling all sort of primitive types).
First of all, thanks for the answer! That MR looked great to me but there seems to be a lot going on ... meanwhile, both Firefox and Chromium implemented the cloning of In TC39 I've been told Structured Clone is WHATWG responsibility and it was indeed confusing to me, but seeing all sort of native Web (only?) classes as part of the algorithm made me wonder where this spec should be moved forward 'cause it looks like "no matter where" there will be back and forward alignment between these two spaces.
By no mean I want these two browsers to remove that wonderful (and expected) non-specified feature but how difficult could it be to just make the status-quo official so that WebKit can follow at least that Or is it even possible/desired? 'cause moving this over ECMAScript and then start fresh all issues around this algorithm will take a huge amount of time and a lot of discussions will be lost in the process ... but I understand current state is not ideal at all, I am just worried nothing will happen for years if we move this essential part of the Web somewhere else at this point in time. |
I think Step 17.6. of StructuredSerializeInternal explicitly allows us to serialize additional data:
|
Step 17.6 only allows you to attach not yet specified data. You're not allowed to attach specified data, such as |
fair enough ... but ... if I feel like Accordingly, the OP intent is to not change anything but cause field in the current algorithm so that nobody except eventually the WebKit team needs to comply with that amend and we can use, until things are settled in a way or another, a field that helps circumventing every limitation we have right now with errors, no matters where these come from. Is this a possibility? |
What is the issue with the HTML Standard?
In step 17 of StructuredSerializeInternal it's mentioned that, beside
type
,message
andname
(not super useful for developers):Now, the base Error class has only 2 fields:
message
and cause.The MDN description for
cause
is:Accordingly, you can imagine my disappointment when I've realized that while Chrome/ium and Firefox clone that field too, WebKit doesn't clone it and it's impossible to attach relevant Error details to anything that is going to be forwarded via
postMessage(thatError)
.The test is pretty simple:
This fails in WebKit but it looks to me that field must be forwarded for cross platform, cross browser, and cross realm compatibility sake, so that having it unspecified as MUST like it is for
message
,type
andname
feels like a bug/hazard when better error messages, propagation or handling, is desired in any program that works on the main or any other worker based thread./cc @rniwa here because both WebKit and Bun (or anything JSC based) is making it impossible for us to provide better errors when WASM non-blocking code generates errors within Workers (Service, Shared, or regular).
Thanks in advance for considering a fix to this part, it's the only field that currently gives developers any extra power to attach more to errors and having it unusable due lack of cross engine compatibilities feels like a huge mistake/limitation.
The text was updated successfully, but these errors were encountered: