Title: TypeError: "fetch" is read-only in firefox add-on only · Issue #36142 · angular/angular · GitHub
Open Graph Title: TypeError: "fetch" is read-only in firefox add-on only · Issue #36142 · angular/angular
X Title: TypeError: "fetch" is read-only in firefox add-on only · Issue #36142 · angular/angular
Description: I've developed Extension using Angular 9 which works well on Chrome but not on firefox, result in TypeError: "fetch" is read-only. I tried updating Angular 9.0.1 to 9.0.7 and also updating zone.js from 0.10.2 to 0.10.3 but no success. Th...
Open Graph Description: I've developed Extension using Angular 9 which works well on Chrome but not on firefox, result in TypeError: "fetch" is read-only. I tried updating Angular 9.0.1 to 9.0.7 and also updating zone.js ...
X Description: I've developed Extension using Angular 9 which works well on Chrome but not on firefox, result in TypeError: "fetch" is read-only. I tried updating Angular 9.0.1 to 9.0.7 and also upd...
Opengraph URL: https://github.com/angular/angular/issues/36142
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TypeError: \"fetch\" is read-only in firefox add-on only","articleBody":"I've developed Extension using Angular 9 which works well on Chrome but not on firefox, result in TypeError: \"fetch\" is read-only. I tried updating Angular 9.0.1 to 9.0.7 and also updating zone.js from 0.10.2 to 0.10.3 but no success. The stack of error as follows\r\n```\r\n Zone.__load_patch('ZoneAwarePromise', (global, Zone, api) => {\r\n const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\r\n const ObjectDefineProperty = Object.defineProperty;\r\n function readableObjectToString(obj) {\r\n if (obj && obj.toString === Object.prototype.toString) {\r\n const className = obj.constructor && obj.constructor.name;\r\n return (className ? className : '') + ': ' + JSON.stringify(obj);\r\n }\r\n return obj ? obj.toString() : Object.prototype.toString.call(obj);\r\n }\r\n const __symbol__ = api.symbol;\r\n const _uncaughtPromiseErrors = [];\r\n const symbolPromise = __symbol__('Promise');\r\n const symbolThen = __symbol__('then');\r\n const creationTrace = '__creationTrace__';\r\n api.onUnhandledError = (e) => {\r\n if (api.showUncaughtError()) {\r\n const rejection = e && e.rejection;\r\n if (rejection) {\r\n console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined);\r\n }\r\n else {\r\n console.error(e);\r\n }\r\n }\r\n };\r\n api.microtaskDrainDone = () => {\r\n while (_uncaughtPromiseErrors.length) {\r\n while (_uncaughtPromiseErrors.length) {\r\n const uncaughtPromiseError = _uncaughtPromiseErrors.shift();\r\n try {\r\n uncaughtPromiseError.zone.runGuarded(() => { throw uncaughtPromiseError; });\r\n }\r\n catch (error) {\r\n handleUnhandledRejection(error);\r\n }\r\n }\r\n }\r\n };\r\n const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler');\r\n function handleUnhandledRejection(e) {\r\n api.onUnhandledError(e);\r\n try {\r\n const handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL];\r\n if (handler && typeof handler === 'function') {\r\n handler.call(this, e);\r\n }\r\n }\r\n catch (err) {\r\n }\r\n }\r\n function isThenable(value) { return value && value.then; }\r\n function forwardResolution(value) { return value; }\r\n function forwardRejection(rejection) { return ZoneAwarePromise.reject(rejection); }\r\n const symbolState = __symbol__('state');\r\n const symbolValue = __symbol__('value');\r\n const symbolFinally = __symbol__('finally');\r\n const symbolParentPromiseValue = __symbol__('parentPromiseValue');\r\n const symbolParentPromiseState = __symbol__('parentPromiseState');\r\n const source = 'Promise.then';\r\n const UNRESOLVED = null;\r\n const RESOLVED = true;\r\n const REJECTED = false;\r\n const REJECTED_NO_CATCH = 0;\r\n function makeResolver(promise, state) {\r\n return (v) => {\r\n try {\r\n resolvePromise(promise, state, v);\r\n }\r\n catch (err) {\r\n resolvePromise(promise, false, err);\r\n }\r\n // Do not return value or you will break the Promise spec.\r\n };\r\n }\r\n const once = function () {\r\n let wasCalled = false;\r\n return function wrapper(wrappedFunction) {\r\n return function () {\r\n if (wasCalled) {\r\n return;\r\n }\r\n wasCalled = true;\r\n wrappedFunction.apply(null, arguments);\r\n };\r\n };\r\n };\r\n const TYPE_ERROR = 'Promise resolved with itself';\r\n const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace');\r\n // Promise Resolution\r\n function resolvePromise(promise, state, value) {\r\n const onceWrapper = once();\r\n if (promise === value) {\r\n throw new TypeError(TYPE_ERROR);\r\n }\r\n if (promise[symbolState] === UNRESOLVED) {\r\n // should only get value.then once based on promise spec.\r\n let then = null;\r\n try {\r\n if (typeof value === 'object' || typeof value === 'function') {\r\n then = value && value.then;\r\n }\r\n }\r\n catch (err) {\r\n onceWrapper(() => { resolvePromise(promise, false, err); })();\r\n return promise;\r\n }\r\n // if (value instanceof ZoneAwarePromise) {\r\n if (state !== REJECTED && value instanceof ZoneAwarePromise &&\r\n value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) &&\r\n value[symbolState] !== UNRESOLVED) {\r\n clearRejectedNoCatch(value);\r\n resolvePromise(promise, value[symbolState], value[symbolValue]);\r\n }\r\n else if (state !== REJECTED && typeof then === 'function') {\r\n try {\r\n then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)));\r\n }\r\n catch (err) {\r\n onceWrapper(() => { resolvePromise(promise, false, err); })();\r\n }\r\n }\r\n else {\r\n promise[symbolState] = state;\r\n const queue = promise[symbolValue];\r\n promise[symbolValue] = value;\r\n if (promise[symbolFinally] === symbolFinally) {\r\n // the promise is generated by Promise.prototype.finally\r\n if (state === RESOLVED) {\r\n // the state is resolved, should ignore the value\r\n // and use parent promise value\r\n promise[symbolState] = promise[symbolParentPromiseState];\r\n promise[symbolValue] = promise[symbolParentPromiseValue];\r\n }\r\n }\r\n // record task information in value when error occurs, so we can\r\n // do some additional work such as render longStackTrace\r\n if (state === REJECTED && value instanceof Error) {\r\n // check if longStackTraceZone is here\r\n const trace = Zone.currentTask && Zone.currentTask.data &&\r\n Zone.currentTask.data[creationTrace];\r\n if (trace) {\r\n // only keep the long stack trace into error when in longStackTraceZone\r\n ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace });\r\n }\r\n }\r\n for (let i = 0; i \u003c queue.length;) {\r\n scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]);\r\n }\r\n if (queue.length == 0 && state == REJECTED) {\r\n promise[symbolState] = REJECTED_NO_CATCH;\r\n try {\r\n // try to print more readable error log\r\n throw new Error('Uncaught (in promise): ' + readableObjectToString(value) +\r\n (value && value.stack ? '\\n' + value.stack : ''));\r\n }\r\n catch (err) {\r\n const error = err;\r\n error.rejection = value;\r\n error.promise = promise;\r\n error.zone = Zone.current;\r\n error.task = Zone.currentTask;\r\n _uncaughtPromiseErrors.push(error);\r\n api.scheduleMicroTask(); // to make sure that it is running\r\n }\r\n }\r\n }\r\n }\r\n // Resolving an already resolved promise is a noop.\r\n return promise;\r\n }\r\n const REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler');\r\n function clearRejectedNoCatch(promise) {\r\n if (promise[symbolState] === REJECTED_NO_CATCH) {\r\n // if the promise is rejected no catch status\r\n // and queue.length > 0, means there is a error handler\r\n // here to handle the rejected promise, we should trigger\r\n // windows.rejectionhandled eventHandler or nodejs rejectionHandled\r\n // eventHandler\r\n try {\r\n const handler = Zone[REJECTION_HANDLED_HANDLER];\r\n if (handler && typeof handler === 'function') {\r\n handler.call(this, { rejection: promise[symbolValue], promise: promise });\r\n }\r\n }\r\n catch (err) {\r\n }\r\n promise[symbolState] = REJECTED;\r\n for (let i = 0; i \u003c _uncaughtPromiseErrors.length; i++) {\r\n if (promise === _uncaughtPromiseErrors[i].promise) {\r\n _uncaughtPromiseErrors.splice(i, 1);\r\n }\r\n }\r\n }\r\n }\r\n function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) {\r\n clearRejectedNoCatch(promise);\r\n const promiseState = promise[symbolState];\r\n const delegate = promiseState ?\r\n (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution :\r\n (typeof onRejected === 'function') ? onRejected : forwardRejection;\r\n zone.scheduleMicroTask(source, () => {\r\n try {\r\n const parentPromiseValue = promise[symbolValue];\r\n const isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally];\r\n if (isFinallyPromise) {\r\n // if the promise is generated from finally call, keep parent promise's state and value\r\n chainPromise[symbolParentPromiseValue] = parentPromiseValue;\r\n chainPromise[symbolParentPromiseState] = promiseState;\r\n }\r\n // should not pass value to finally callback\r\n const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ?\r\n [] :\r\n [parentPromiseValue]);\r\n resolvePromise(chainPromise, true, value);\r\n }\r\n catch (error) {\r\n // if error occurs, should always return this error\r\n resolvePromise(chainPromise, false, error);\r\n }\r\n }, chainPromise);\r\n }\r\n const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }';\r\n class ZoneAwarePromise {\r\n constructor(executor) {\r\n const promise = this;\r\n if (!(promise instanceof ZoneAwarePromise)) {\r\n throw new Error('Must be an instanceof Promise.');\r\n }\r\n promise[symbolState] = UNRESOLVED;\r\n promise[symbolValue] = []; // queue;\r\n try {\r\n executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED));\r\n }\r\n catch (error) {\r\n resolvePromise(promise, false, error);\r\n }\r\n }\r\n static toString() { return ZONE_AWARE_PROMISE_TO_STRING; }\r\n static resolve(value) {\r\n return resolvePromise(new this(null), RESOLVED, value);\r\n }\r\n static reject(error) {\r\n return resolvePromise(new this(null), REJECTED, error);\r\n }\r\n static race(values) {\r\n let resolve;\r\n let reject;\r\n let promise = new this((res, rej) => {\r\n resolve = res;\r\n reject = rej;\r\n });\r\n function onResolve(value) { resolve(value); }\r\n function onReject(error) { reject(error); }\r\n for (let value of values) {\r\n if (!isThenable(value)) {\r\n value = this.resolve(value);\r\n }\r\n value.then(onResolve, onReject);\r\n }\r\n return promise;\r\n }\r\n static all(values) { return ZoneAwarePromise.allWithCallback(values); }\r\n static allSettled(values) {\r\n const P = this && this.prototype instanceof ZoneAwarePromise ? this : ZoneAwarePromise;\r\n return P.allWithCallback(values, {\r\n thenCallback: (value) => ({ status: 'fulfilled', value }),\r\n errorCallback: (err) => ({ status: 'rejected', reason: err })\r\n });\r\n }\r\n static allWithCallback(values, callback) {\r\n let resolve;\r\n let reject;\r\n let promise = new this((res, rej) => {\r\n resolve = res;\r\n reject = rej;\r\n });\r\n // Start at 2 to prevent prematurely resolving if .then is called immediately.\r\n let unresolvedCount = 2;\r\n let valueIndex = 0;\r\n const resolvedValues = [];\r\n for (let value of values) {\r\n if (!isThenable(value)) {\r\n value = this.resolve(value);\r\n }\r\n const curValueIndex = valueIndex;\r\n try {\r\n value.then((value) => {\r\n resolvedValues[curValueIndex] = callback ? callback.thenCallback(value) : value;\r\n unresolvedCount--;\r\n if (unresolvedCount === 0) {\r\n resolve(resolvedValues);\r\n }\r\n }, (err) => {\r\n if (!callback) {\r\n reject(err);\r\n }\r\n else {\r\n resolvedValues[curValueIndex] = callback.errorCallback(err);\r\n unresolvedCount--;\r\n if (unresolvedCount === 0) {\r\n resolve(resolvedValues);\r\n }\r\n }\r\n });\r\n }\r\n catch (thenErr) {\r\n reject(thenErr);\r\n }\r\n unresolvedCount++;\r\n valueIndex++;\r\n }\r\n // Make the unresolvedCount zero-based again.\r\n unresolvedCount -= 2;\r\n if (unresolvedCount === 0) {\r\n resolve(resolvedValues);\r\n }\r\n return promise;\r\n }\r\n get [Symbol.toStringTag]() { return 'Promise'; }\r\n then(onFulfilled, onRejected) {\r\n const chainPromise = new this.constructor(null);\r\n const zone = Zone.current;\r\n if (this[symbolState] == UNRESOLVED) {\r\n this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected);\r\n }\r\n else {\r\n scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected);\r\n }\r\n return chainPromise;\r\n }\r\n catch(onRejected) {\r\n return this.then(null, onRejected);\r\n }\r\n finally(onFinally) {\r\n const chainPromise = new this.constructor(null);\r\n chainPromise[symbolFinally] = symbolFinally;\r\n const zone = Zone.current;\r\n if (this[symbolState] == UNRESOLVED) {\r\n this[symbolValue].push(zone, chainPromise, onFinally, onFinally);\r\n }\r\n else {\r\n scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally);\r\n }\r\n return chainPromise;\r\n }\r\n }\r\n // Protect against aggressive optimizers dropping seemingly unused properties.\r\n // E.g. Closure Compiler in advanced mode.\r\n ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve;\r\n ZoneAwarePromise['reject'] = ZoneAwarePromise.reject;\r\n ZoneAwarePromise['race'] = ZoneAwarePromise.race;\r\n ZoneAwarePromise['all'] = ZoneAwarePromise.all;\r\n const NativePromise = global[symbolPromise] = global['Promise'];\r\n const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise');\r\n let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise');\r\n if (!desc || desc.configurable) {\r\n desc && delete desc.writable;\r\n desc && delete desc.value;\r\n if (!desc) {\r\n desc = { configurable: true, enumerable: true };\r\n }\r\n desc.get = function () {\r\n // if we already set ZoneAwarePromise, use patched one\r\n // otherwise return native one.\r\n return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise];\r\n };\r\n desc.set = function (NewNativePromise) {\r\n if (NewNativePromise === ZoneAwarePromise) {\r\n // if the NewNativePromise is ZoneAwarePromise\r\n // save to global\r\n global[ZONE_AWARE_PROMISE] = NewNativePromise;\r\n }\r\n else {\r\n // if the NewNativePromise is not ZoneAwarePromise\r\n // for example: after load zone.js, some library just\r\n // set es6-promise to global, if we set it to global\r\n // directly, assertZonePatched will fail and angular\r\n // will not loaded, so we just set the NewNativePromise\r\n // to global[symbolPromise], so the result is just like\r\n // we load ES6 Promise before zone.js\r\n global[symbolPromise] = NewNativePromise;\r\n if (!NewNativePromise.prototype[symbolThen]) {\r\n patchThen(NewNativePromise);\r\n }\r\n api.setNativePromise(NewNativePromise);\r\n }\r\n };\r\n ObjectDefineProperty(global, 'Promise', desc);\r\n }\r\n global['Promise'] = ZoneAwarePromise;\r\n const symbolThenPatched = __symbol__('thenPatched');\r\n function patchThen(Ctor) {\r\n const proto = Ctor.prototype;\r\n const prop = ObjectGetOwnPropertyDescriptor(proto, 'then');\r\n if (prop && (prop.writable === false || !prop.configurable)) {\r\n // check Ctor.prototype.then propertyDescriptor is writable or not\r\n // in meteor env, writable is false, we should ignore such case\r\n return;\r\n }\r\n const originalThen = proto.then;\r\n // Keep a reference to the original method.\r\n proto[symbolThen] = originalThen;\r\n Ctor.prototype.then = function (onResolve, onReject) {\r\n const wrapped = new ZoneAwarePromise((resolve, reject) => { originalThen.call(this, resolve, reject); });\r\n return wrapped.then(onResolve, onReject);\r\n };\r\n Ctor[symbolThenPatched] = true;\r\n }\r\n api.patchThen = patchThen;\r\n function zoneify(fn) {\r\n return function () {\r\n let resultPromise = fn.apply(this, arguments);\r\n if (resultPromise instanceof ZoneAwarePromise) {\r\n return resultPromise;\r\n }\r\n let ctor = resultPromise.constructor;\r\n if (!ctor[symbolThenPatched]) {\r\n patchThen(ctor);\r\n }\r\n return resultPromise;\r\n };\r\n }\r\n if (NativePromise) {\r\n patchThen(NativePromise);\r\n const fetch = global['fetch'];\r\n if (typeof fetch == 'function') {\r\n global[api.symbol('fetch')] = fetch;\r\n global['fetch'] = zoneify(fetch);\r\n }\r\n }\r\n // This is not part of public API, but it is useful for tests, so we expose it.\r\n Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors;\r\n return ZoneAwarePromise;\r\n })\r\n```","author":{"url":"https://github.com/Sharan3009","@type":"Person","name":"Sharan3009"},"datePublished":"2020-03-19T13:27:59Z","url":"https://github.com/angular/angular/issues/36142"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6fcb95f6-2382-963e-9cbc-0efa44ab4895 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C930:4BB79:1B83A1B:2315327:6B0159CB |
| html-safe-nonce | 5e655e46e82bb3f6ea46bfaeb4b6838d55ffd4564eff229ee227e5b5e642e4fe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTMwOjRCQjc5OjFCODNBMUI6MjMxNTMyNzo2QjAxNTlDQiIsInZpc2l0b3JfaWQiOiI4Njg2Njc1MzY5MTc4MjU3ODY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5132d1d435d9fa3560e8dd331470f512eb47f352bbac81e0913994403fda1207 |
| hovercard-subject-tag | issue:584412372 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/36142/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d4928afc210535c4f4a6a457cce50254a7c8da65f8c03db24b635e1954d88d6/angular/angular/issues/36142 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d4928afc210535c4f4a6a457cce50254a7c8da65f8c03db24b635e1954d88d6/angular/angular/issues/36142 |
| og:image:alt | I've developed Extension using Angular 9 which works well on Chrome but not on firefox, result in TypeError: "fetch" is read-only. I tried updating Angular 9.0.1 to 9.0.7 and also updating zone.js ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Sharan3009 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width