From ce50e533c3a110d1fd5627b40e97b616d03de89d Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Fri, 15 Jul 2022 15:32:45 +1000 Subject: [PATCH 1/5] FF104 Native Error types are serializable --- files/en-us/mozilla/firefox/releases/104/index.md | 7 +++++++ .../structured_clone_algorithm/index.md | 11 ++++++++--- .../reference/global_objects/error/index.md | 2 ++ .../reference/global_objects/evalerror/index.md | 2 ++ .../reference/global_objects/rangeerror/index.md | 2 ++ .../reference/global_objects/referenceerror/index.md | 2 ++ .../reference/global_objects/syntaxerror/index.md | 2 ++ .../reference/global_objects/typeerror/index.md | 2 ++ .../reference/global_objects/urierror/index.md | 2 ++ 9 files changed, 29 insertions(+), 3 deletions(-) diff --git a/files/en-us/mozilla/firefox/releases/104/index.md b/files/en-us/mozilla/firefox/releases/104/index.md index d4983a7669d3534..0aaa4731caf17ae 100644 --- a/files/en-us/mozilla/firefox/releases/104/index.md +++ b/files/en-us/mozilla/firefox/releases/104/index.md @@ -25,6 +25,13 @@ This article provides information about the changes in Firefox 104 that will aff ### JavaScript +- Native Error types can now be serialized using the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). + This includes {{JSxRef("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} and {{JSxRef("AggregateError")}}. + Serialized properties include the [`name`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name), [`message`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message), [`cause`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause), [`fileName`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName), [`lineNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber) and [`columnNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber). + [`stack`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack) is only serialized in the nightly builds ({{bug(1774866)}}). + For {{JSxRef("AggregateError")}} the `message`, `name`, `cause` and `errors` properties are serialized + See {{bug(1556604)}} for more details. + #### Removals ### HTTP diff --git a/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md b/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md index 4c06f21c74b7328..236d1c3440131d7 100644 --- a/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md +++ b/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md @@ -27,9 +27,6 @@ It clones by recursing through the input object while maintaining a map of previ For example, if an object is marked readonly with a [property descriptor](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor), it will be read/write in the duplicate, since that's the default. - The prototype chain is not walked or duplicated. -> **Note:** Native {{jsxref("Error")}} types can be cloned in Chrome. -> Firefox can clone {{domxref("DOMException")}}, and is [working on the other error types](https://bugzilla.mozilla.org/show_bug.cgi?id=1556604). - ## Supported types @@ -114,6 +111,14 @@ It clones by recursing through the input object while maintaining a map of previ + + + +
{{domxref("DOMException")}} Most browsers only clone the properties {{domxref("DOMException.name","name")}} and {{domxref("DOMException.message","message")}} (in theory stack traces and other attributes may also be cloned).
Native Error types +

The error name must be one of: {{jsxref("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} (or will be set to "Error").

+

Browsers must serialize the properties name and message, and are expected to serialise "interesting" other properties of the errors such as stack, cause, etc.

+

{{JSxRef("AggregateError")}} support is expected to be added to the specification in whatwg/html/#5749 (and is already supported in some browsers).

+
diff --git a/files/en-us/web/javascript/reference/global_objects/error/index.md b/files/en-us/web/javascript/reference/global_objects/error/index.md index 4f7007c52893334..b7bbcc75f023380 100644 --- a/files/en-us/web/javascript/reference/global_objects/error/index.md +++ b/files/en-us/web/javascript/reference/global_objects/error/index.md @@ -17,6 +17,8 @@ browser-compat: javascript.builtins.Error Runtime errors result in new `Error` objects being created and thrown. +`Error` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ### Error types Besides the generic `Error` constructor, there are other core error constructors in JavaScript. For client-side exceptions, see [Exception handling statements](/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling#exception_handling_statements). diff --git a/files/en-us/web/javascript/reference/global_objects/evalerror/index.md b/files/en-us/web/javascript/reference/global_objects/evalerror/index.md index 77cf8c5734c62e2..121cfc718965d2e 100644 --- a/files/en-us/web/javascript/reference/global_objects/evalerror/index.md +++ b/files/en-us/web/javascript/reference/global_objects/evalerror/index.md @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.EvalError The **`EvalError`** object indicates an error regarding the global {{jsxref("Global_Objects/eval", "eval()")}} function. This exception is not thrown by JavaScript anymore, however the `EvalError` object remains for compatibility. +`EvalError` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ## Constructor - {{jsxref("EvalError/EvalError", "EvalError()")}} diff --git a/files/en-us/web/javascript/reference/global_objects/rangeerror/index.md b/files/en-us/web/javascript/reference/global_objects/rangeerror/index.md index 9d32075d20a7867..77a44e035b39c1e 100644 --- a/files/en-us/web/javascript/reference/global_objects/rangeerror/index.md +++ b/files/en-us/web/javascript/reference/global_objects/rangeerror/index.md @@ -22,6 +22,8 @@ This can be encountered when: - when attempting to create an array of an illegal length with the {{jsxref("Array")}} constructor, or - when passing bad values to the numeric methods {{jsxref("Number.prototype.toExponential()")}}, {{jsxref("Number.prototype.toFixed()")}} or {{jsxref("Number.prototype.toPrecision()")}}. +`RangeError` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ## Constructor - {{jsxref("RangeError/RangeError", "RangeError()")}} diff --git a/files/en-us/web/javascript/reference/global_objects/referenceerror/index.md b/files/en-us/web/javascript/reference/global_objects/referenceerror/index.md index 1c58bbd8c18afce..8bd1addd0e244bb 100644 --- a/files/en-us/web/javascript/reference/global_objects/referenceerror/index.md +++ b/files/en-us/web/javascript/reference/global_objects/referenceerror/index.md @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.ReferenceError The **`ReferenceError`** object represents an error when a variable that doesn't exist (or hasn't yet been initialized) in the current scope is referenced. +`ReferenceError` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ## Constructor - {{jsxref("Global_Objects/ReferenceError/ReferenceError", "ReferenceError()")}} diff --git a/files/en-us/web/javascript/reference/global_objects/syntaxerror/index.md b/files/en-us/web/javascript/reference/global_objects/syntaxerror/index.md index df8e3a479178178..1514e4afd8ddec1 100644 --- a/files/en-us/web/javascript/reference/global_objects/syntaxerror/index.md +++ b/files/en-us/web/javascript/reference/global_objects/syntaxerror/index.md @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.SyntaxError The **`SyntaxError`** object represents an error when trying to interpret syntactically invalid code. It is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code. +`SyntaxError` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ## Constructor - {{jsxref("Global_Objects/SyntaxError/SyntaxError", "SyntaxError()")}} diff --git a/files/en-us/web/javascript/reference/global_objects/typeerror/index.md b/files/en-us/web/javascript/reference/global_objects/typeerror/index.md index 44959bc235aabfd..b2ad35bc635e4d3 100644 --- a/files/en-us/web/javascript/reference/global_objects/typeerror/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typeerror/index.md @@ -19,6 +19,8 @@ A `TypeError` may be thrown when: - when attempting to modify a value that cannot be changed; or - when attempting to use a value in an inappropriate way. +`TypeError` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ## Constructor - {{jsxref("Global_Objects/TypeError/TypeError", "TypeError()")}} diff --git a/files/en-us/web/javascript/reference/global_objects/urierror/index.md b/files/en-us/web/javascript/reference/global_objects/urierror/index.md index b13cfd5956a04ca..6a40466dc31afbb 100644 --- a/files/en-us/web/javascript/reference/global_objects/urierror/index.md +++ b/files/en-us/web/javascript/reference/global_objects/urierror/index.md @@ -13,6 +13,8 @@ browser-compat: javascript.builtins.URIError The **`URIError`** object represents an error when a global URI handling function was used in a wrong way. +`URIError` is a {{Glossary("serializable object")}}, so it can be cloned with {{domxref("structuredClone()")}} or copied between [Workers](/en-US/docs/Web/API/Worker) using {{domxref("Worker.postMessage()", "postMessage()")}}. + ## Constructor - {{jsxref("Global_Objects/URIError/URIError", "URIError()")}} From 0d66b27fa465c5689e7a60a2ee5c78636e235989 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Fri, 15 Jul 2022 16:04:42 +1000 Subject: [PATCH 2/5] Fix error - this is in FF103, not 104 --- files/en-us/mozilla/firefox/releases/103/index.md | 7 +++++++ files/en-us/mozilla/firefox/releases/104/index.md | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/files/en-us/mozilla/firefox/releases/103/index.md b/files/en-us/mozilla/firefox/releases/103/index.md index ba711b16307891d..8e9a4bf24aecaa9 100644 --- a/files/en-us/mozilla/firefox/releases/103/index.md +++ b/files/en-us/mozilla/firefox/releases/103/index.md @@ -25,6 +25,13 @@ This article provides information about the changes in Firefox 103 that will aff ### JavaScript +- Native Error types can now be serialized using the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). + This includes {{JSxRef("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} and {{JSxRef("AggregateError")}}. + Serialized properties include the [`name`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name), [`message`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message), [`cause`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause), [`fileName`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName), [`lineNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber) and [`columnNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber). + [`stack`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack) is only serialized in the nightly builds ({{bug(1774866)}}). + For {{JSxRef("AggregateError")}} the `message`, `name`, `cause` and `errors` properties are serialized + See {{bug(1556604)}} for more details. + #### Removals ### HTTP diff --git a/files/en-us/mozilla/firefox/releases/104/index.md b/files/en-us/mozilla/firefox/releases/104/index.md index 0aaa4731caf17ae..d4983a7669d3534 100644 --- a/files/en-us/mozilla/firefox/releases/104/index.md +++ b/files/en-us/mozilla/firefox/releases/104/index.md @@ -25,13 +25,6 @@ This article provides information about the changes in Firefox 104 that will aff ### JavaScript -- Native Error types can now be serialized using the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). - This includes {{JSxRef("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} and {{JSxRef("AggregateError")}}. - Serialized properties include the [`name`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name), [`message`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message), [`cause`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause), [`fileName`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName), [`lineNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber) and [`columnNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber). - [`stack`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack) is only serialized in the nightly builds ({{bug(1774866)}}). - For {{JSxRef("AggregateError")}} the `message`, `name`, `cause` and `errors` properties are serialized - See {{bug(1556604)}} for more details. - #### Removals ### HTTP From f0dbf769641f9872bccb262073b18a668c0ddf6e Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Jul 2022 09:20:57 +1000 Subject: [PATCH 3/5] Update files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md Co-authored-by: Joshua Chen --- .../web/api/web_workers_api/structured_clone_algorithm/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md b/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md index 236d1c3440131d7..9f6c3fe668cc5f3 100644 --- a/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md +++ b/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md @@ -116,7 +116,7 @@ It clones by recursing through the input object while maintaining a map of previ

The error name must be one of: {{jsxref("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} (or will be set to "Error").

Browsers must serialize the properties name and message, and are expected to serialise "interesting" other properties of the errors such as stack, cause, etc.

-

{{JSxRef("AggregateError")}} support is expected to be added to the specification in whatwg/html/#5749 (and is already supported in some browsers).

+

{{JSxRef("AggregateError")}} support is expected to be added to the specification in whatwg/html#5749 (and is already supported in some browsers).

From 00e4f19703f3b523c4eecbe70b6ad65874f7711c Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Jul 2022 10:16:51 +1000 Subject: [PATCH 4/5] Remove stack info from release note --- files/en-us/mozilla/firefox/releases/103/index.md | 2 +- .../api/web_workers_api/structured_clone_algorithm/index.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/en-us/mozilla/firefox/releases/103/index.md b/files/en-us/mozilla/firefox/releases/103/index.md index 8e9a4bf24aecaa9..3cc40413115a96e 100644 --- a/files/en-us/mozilla/firefox/releases/103/index.md +++ b/files/en-us/mozilla/firefox/releases/103/index.md @@ -28,7 +28,7 @@ This article provides information about the changes in Firefox 103 that will aff - Native Error types can now be serialized using the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). This includes {{JSxRef("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} and {{JSxRef("AggregateError")}}. Serialized properties include the [`name`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name), [`message`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message), [`cause`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause), [`fileName`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName), [`lineNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber) and [`columnNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber). - [`stack`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack) is only serialized in the nightly builds ({{bug(1774866)}}). + For {{JSxRef("AggregateError")}} the `message`, `name`, `cause` and `errors` properties are serialized See {{bug(1556604)}} for more details. diff --git a/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md b/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md index 9f6c3fe668cc5f3..6ada80d16b7d543 100644 --- a/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md +++ b/files/en-us/web/api/web_workers_api/structured_clone_algorithm/index.md @@ -109,7 +109,8 @@ It clones by recursing through the input object while maintaining a map of previ {{domxref("DOMException")}} - Most browsers only clone the properties {{domxref("DOMException.name","name")}} and {{domxref("DOMException.message","message")}} (in theory stack traces and other attributes may also be cloned). + Browsers must serialize the properties {{domxref("DOMException.name","name")}} and {{domxref("DOMException.message","message")}}. + Other attributes may also be serialized/cloned. Native Error types From 22751fbcfb095a471ebfe136a0fa300e6ea44936 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 18 Jul 2022 10:26:29 +1000 Subject: [PATCH 5/5] Update files/en-us/mozilla/firefox/releases/103/index.md --- files/en-us/mozilla/firefox/releases/103/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/mozilla/firefox/releases/103/index.md b/files/en-us/mozilla/firefox/releases/103/index.md index 3cc40413115a96e..67045794013c0f1 100644 --- a/files/en-us/mozilla/firefox/releases/103/index.md +++ b/files/en-us/mozilla/firefox/releases/103/index.md @@ -29,7 +29,7 @@ This article provides information about the changes in Firefox 103 that will aff This includes {{JSxRef("Error")}}, {{JSxRef("EvalError")}}, {{JSxRef("RangeError")}}, {{JSxRef("ReferenceError")}}, {{JSxRef("SyntaxError")}}, {{JSxRef("TypeError")}}, {{JSxRef("URIError")}} and {{JSxRef("AggregateError")}}. Serialized properties include the [`name`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name), [`message`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message), [`cause`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause), [`fileName`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName), [`lineNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber) and [`columnNumber`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber). - For {{JSxRef("AggregateError")}} the `message`, `name`, `cause` and `errors` properties are serialized + For {{JSxRef("AggregateError")}} the `message`, `name`, `cause` and `errors` properties are serialized. See {{bug(1556604)}} for more details. #### Removals