commit 63a518731e56d809573217016ed0e0fc8a2f9732
parent 54d5972c80392b1dbb6e01d0d89f858ca662a56c
Author: Greg Tatum <tatum.creative@gmail.com>
Date: Thu, 2 Oct 2025 19:35:07 +0000
Bug 1990084 - Fix an issue with EXCEPTION_NAMES being empty in the execution environment; r=tarek
There is something strange going on with the PromiseWorker where the
local variables are not showing up. This causes an exception that hides
an error from being properly propagated from the worker.
Differential Revision: https://phabricator.services.mozilla.com/D265708
Diffstat:
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/toolkit/components/promiseworker/worker/PromiseWorker.template.worker.js b/toolkit/components/promiseworker/worker/PromiseWorker.template.worker.js
@@ -36,20 +36,6 @@ importScripts("resource://gre/modules/workers/require.js");
// #END_SCRIPT_ONLY
/**
- * Built-in JavaScript exceptions that may be serialized without
- * loss of information.
- */
-const EXCEPTION_NAMES = {
- EvalError: "EvalError",
- InternalError: "InternalError",
- RangeError: "RangeError",
- ReferenceError: "ReferenceError",
- SyntaxError: "SyntaxError",
- TypeError: "TypeError",
- URIError: "URIError",
-};
-
-/**
* A constructor used to return data to the caller thread while
* also executing some specific treatment (e.g. shutting down
* the current thread, transmitting data instead of copying it).
@@ -104,6 +90,17 @@ function AbstractWorker(agent) {
this._agent = agent;
this._deferredJobs = new Map();
this._deferredJobId = 0;
+ // Built-in JavaScript exceptions that may be serialized without
+ // loss of information.
+ this._exceptionNames = {
+ EvalError: "EvalError",
+ InternalError: "InternalError",
+ RangeError: "RangeError",
+ ReferenceError: "ReferenceError",
+ SyntaxError: "SyntaxError",
+ TypeError: "TypeError",
+ URIError: "URIError",
+ };
}
AbstractWorker.prototype = {
@@ -225,7 +222,7 @@ AbstractWorker.prototype = {
message: exn.message,
};
this.postMessage({ fail: error, id, durationMs });
- } else if (exn.constructor.name in EXCEPTION_NAMES) {
+ } else if (exn.constructor.name in this._exceptionNames) {
// Rather than letting the DOM mechanism [de]serialize built-in
// JS errors, which loses lots of information (in particular,
// the constructor name, the moduleName and the moduleStack),