Bugzilla Report Package
Product: Developer Tools
Component: General / Debugger
Title: [Source Map Loader] Worker crash due to unhandled JSON.parse error on non-JSON/HTML responses in fetchSourceMap.js
Description:
When fetching source maps in a worker context, fetchSourceMap.js occasionally encounters an unexpected non-JSON response (such as an HTML error page or 404 response starting with ). This causes an unhandled JSON.parse exception at line 83 (_fetch), crashing the source map consumer.
Stack Trace:
Plaintext
Source map error: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Stack in the worker:
parseSourceMapInput@resource://devtools/client/shared/vendor/source-map/lib/util.js:163:15
_factory@resource://devtools/client/shared/vendor/source-map/lib/source-map-consumer.js:1069:22
SourceMapConsumer@resource://devtools/client/shared/vendor/source-map/lib/source-map-consumer.js:26:12
_fetch@resource://devtools/client/shared/source-map-loader/utils/fetchSourceMap.js:83:19
Proposed Patch (fetchSourceMap.js - Line 83):
JavaScript
// Replace direct unhandled parse at line 83 with safe parsing:
const sourceMap = (() => {
try {
const trimmed = responseText ? responseText.trim() : "";
if (trimmed.startsWith("<") || trimmed.startsWith("
})();
Bugzilla Report Package
Product: Developer Tools
Component: General / Debugger
Title: [Source Map Loader] Worker crash due to unhandled JSON.parse error on non-JSON/HTML responses in fetchSourceMap.js
Description:
When fetching source maps in a worker context, fetchSourceMap.js occasionally encounters an unexpected non-JSON response (such as an HTML error page or 404 response starting with <!DOCTYPE html>). This causes an unhandled JSON.parse exception at line 83 (_fetch), crashing the source map consumer.
Stack Trace:
Plaintext
Source map error: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Stack in the worker:
parseSourceMapInput@resource://devtools/client/shared/vendor/source-map/lib/util.js:163:15
_factory@resource://devtools/client/shared/vendor/source-map/lib/source-map-consumer.js:1069:22
SourceMapConsumer@resource://devtools/client/shared/vendor/source-map/lib/source-map-consumer.js:26:12
_fetch@resource://devtools/client/shared/source-map-loader/utils/fetchSourceMap.js:83:19
Proposed Patch (fetchSourceMap.js - Line 83):
JavaScript
// Replace direct unhandled parse at line 83 with safe parsing:
const sourceMap = (() => {
try {
const trimmed = responseText ? responseText.trim() : "";
if (trimmed.startsWith("<") || trimmed.startsWith("<!DOCTYPE")) {
throw new Error("Received HTML instead of JSON");
}
return JSON.parse(responseText);
} catch (err) {
console.warn(`SourceMapLoader: Failed to parse source map.`, err);
return null;
}
})();