Closed Bug 1767424 Opened 2 years ago Closed 2 years ago

structured clone algorithm (`structuredClone`, `History.prototype.replaceState` etc) refuses to clone `Error` object(s)

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 99
defect

Tracking

()

RESOLVED DUPLICATE of bug 1556604

People

(Reporter: armen.michaeli, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

Steps to reproduce:

Called structuredClone with new DOMException("Hello world", "AbortError"). Alternatively, called the former with new Error("Hello").

Actual results:

The method threw a "DataCloneError" error of class DOMException with the message "The object could not be cloned.".

Expected results:

I would expect structurally cloning relatively simple Error objects (or some/all of their subclasses, like DOMException) to succeed. Granted, I am not sure HTML 5 specifically mandates Error objects be cloned or not -- https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal puts in a way where it might depend on implementation -- for example if Firefox considers Error to be serializable in the first place. Steps 17, 19 and 20 in the list describing the algorithm, may be relevant.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE

Thanks Tom. I couldn't find the duplicate issue (Bugzilla listed something it found but the one you linked wasn't listed).

You need to log in before you can comment on or make changes to this bug.