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

FF103 Errors are serializable (support structuredClone) #17008

Merged
merged 1 commit into from
Jul 19, 2022

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented Jul 15, 2022

FF103 adds support for serializing native error classes in https://bugzilla.mozilla.org/show_bug.cgi?id=1556604#c33

Note that

  • this supports both standard and non-standard error properties (name, message, cause, fileName, lineNumber and columnNumber). The stack property is still only supported in nightly.
  • it works for all the normal error types except for InternalError
  • AggregateError support is in FF but this is not yet in spec so that is added but marked as "non-standard". This includes the errors field.
  • I added info about the supported properties as a Note rather than as properties because the spec is fairly loose about what needs to be supported - essentially it is name + message + "any interesting properties.

Related docs work can be tracked in #18208

@github-actions github-actions bot added the data:js 📟 Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript label Jul 15, 2022
@hamishwillee hamishwillee marked this pull request as ready for review July 15, 2022 04:10
@hamishwillee
Copy link
Collaborator Author

@queengooborg FYI - would be good to get review on this when you are ready.

@zloirock
Copy link

They are serializable from FF103. FF104 can clone Error (but still not DOMException) .stack.

@hamishwillee hamishwillee changed the title FF104 Errors are serializable (support structuredClone) FF103 Errors are serializable (support structuredClone) Jul 15, 2022
@hamishwillee
Copy link
Collaborator Author

Hi @zloirock - I just noticed I got this wrong - fixed.

@hamishwillee
Copy link
Collaborator Author

PS @zloirock, according to @evilpie FF104 nightly (only) can clone Error.stack. I have captured this in a note since I don't want to do a subfeature for every field that might be serializable. I'll update the note once Error.stack serialization is supported in proper releases.

@evilpie
Copy link
Contributor

evilpie commented Jul 15, 2022

PS @zloirock, according to @evilpie FF104 nightly (only) can clone Error.stack. I have captured this in a note since I don't want to do a subfeature for every field that might be serializable. I'll update the note once Error.stack serialization is supported in proper releases.

That's incorrect. We will support stack in 104 not just Nightly. But only in window.postMessage and structuredClone.

@hamishwillee
Copy link
Collaborator Author

hamishwillee commented Jul 17, 2022

Ah, thanks @evilpie . Apologies @zloirock I misinterpreted:

We only support serializing the stack when using the structuredClone API in Nightly at the time of writing this.

So is this right? (just to be very clear):

  • FF103 allows Error.stack to be serialized for postMessage()
  • FF103 allows Error.stack to be serialized (clonable) for structuredClone but in NIGHTLY only.
  • FF104 allows Error.stack to be serialized for both postMessage() and structuredClone() (all builds)
  • FF can clone DOMException, but still not DOMException.stack in FF104.

    Does FF have a stack? It isn't in the spec or documented in DOMException (even as a non-standard property). Are we missing any other properties?

So for FF103 we'd have a note like this one: https://github.com/mdn/browser-compat-data/pull/17008/files#r922916460 - for FF104 we will update again.

@hamishwillee hamishwillee marked this pull request as draft July 17, 2022 23:30
@zloirock
Copy link

IIRC .stack is not serializable / clonable in FF103 and was not even in Nightly, however, I'm not 100% sure about the last statement.

@evilpie
Copy link
Contributor

evilpie commented Jul 18, 2022

Correct. There was no stack serialization support at all in FF103 in Nightly or otherwise. 104 supports structuredClone and window.postMessage.

@hamishwillee hamishwillee marked this pull request as ready for review July 19, 2022 00:35
@hamishwillee
Copy link
Collaborator Author

@queengooborg This is now ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:js 📟 Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants