{"record":{"id":"d2ebc62a5be232f5","repo":"ReactiveX/rxjs","slug":"cannot-initialize-rxjs-observable-polyfill-lab","errorCode":null,"errorMessage":"Cannot initialize @rxjs/observable-polyfill: ${label} is not writable or configurable","messagePattern":"Cannot initialize @rxjs/observable-polyfill: (.+?) is not writable or configurable","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"critical","filePath":"packages/observable-polyfill/src/index.ts","lineNumber":1327,"sourceCode":"    typeof value === 'object' &&\n    value !== null &&\n    typeof (value as Partial<ObservablePolyfillInfo>).packageName === 'string' &&\n    typeof (value as Partial<ObservablePolyfillInfo>).version === 'string'\n  );\n}\n\ninterface PropertyInstallation {\n  readonly key: PropertyKey;\n  readonly label: string;\n  readonly next: PropertyDescriptor;\n  readonly previous: PropertyDescriptor | undefined;\n  readonly target: object;\n}\n\nfunction preparePropertyInstallation(target: object, key: PropertyKey, next: PropertyDescriptor, label: string): PropertyInstallation {\n  const previous = Object.getOwnPropertyDescriptor(target, key);\n  if (!canDefineProperty(target, previous, next)) {\n    throw new TypeError(`Cannot initialize @rxjs/observable-polyfill: ${label} is not writable or configurable`);\n  }\n  return { key, label, next, previous, target };\n}\n\nfunction canDefineProperty(target: object, previous: PropertyDescriptor | undefined, next: PropertyDescriptor): boolean {\n  if (!previous) {\n    return Object.isExtensible(target);\n  }\n  if (previous.configurable) {\n    return true;\n  }\n  if ('value' in previous && 'value' in next && previous.writable) {\n    return next.configurable === false && next.enumerable === previous.enumerable && next.writable !== false;\n  }\n  return false;\n}\n\nfunction installPropertiesAtomically(installations: PropertyInstallation[]): void {","sourceCodeStart":1309,"sourceCodeEnd":1345,"githubUrl":"https://github.com/ReactiveX/rxjs/blob/54796b38a57e6309f9861e174737479bb3f63f61/packages/observable-polyfill/src/index.ts#L1309-L1345","documentation":"During polyfill initialization, preparePropertyInstallation checks whether each global property it must install (Observable, Symbol.observable, Subscriber, etc.) can be safely defined: an existing property is overridable only if it is configurable and (writable or has a writable setter). If a previous occupant of the global is locked down (non-configurable and non-writable), initialization throws this TypeError naming the label that could not be installed.","triggerScenarios":"Importing @rxjs/observable-polyfill in an environment where the target global (e.g. Observable on globalThis) already exists as a non-writable, non-configurable property — e.g. after Object.defineProperty(globalThis, 'Observable', { value: X, writable: false, configurable: false }), or after Object.freeze(globalThis), or a security-hardened/locked-down realm (SES, LavaMoat, snow), or duplicate/conflicting polyfill installs.","commonSituations":"Content-security hardening (frozen globals), sandboxed plugin systems, embedded contexts (VS Code webviews, Salesforce LWC), bundlers double-including the polyfill, another library that installed a frozen Observable first (or a native shim frozen before this module loads).","solutions":["Don't freeze/lock the target global before importing the polyfill; make any pre-existing property configurable (configurable: true) or delete it first.","If a conforming native Observable already exists, ensure the polyfill's selection logic uses it rather than redefining (check for duplicate installs of the polyfill in the bundle).","Dedupe the package (add resolutions/overrides so only one copy of @rxjs/observable-polyfill is bundled).","In locked-down environments, install the polyfill's exports onto local scope rather than globals, or run initialization before lockdown (e.g. before SES lockdown())."],"exampleFix":"// before\nObject.defineProperty(globalThis, 'Observable', { value: MyObs, writable: false, configurable: false });\nimport '@rxjs/observable-polyfill'; // throws\n// after\nimport '@rxjs/observable-polyfill'; // install first\n// or keep the property overridable:\nObject.defineProperty(globalThis, 'Observable', { value: MyObs, writable: true, configurable: true });","handlingStrategy":"validation","validationCode":"const desc = Object.getOwnPropertyDescriptor(globalThis, 'Observable');\nif (desc && (!desc.configurable && desc.writable === false)) {\n  // do not import the polyfill globals; use module exports directly\n}","typeGuard":"function canInstallGlobal(key: PropertyKey): boolean {\n  const d = Object.getOwnPropertyDescriptor(globalThis, key);\n  return !d || d.configurable || !!d.writable || !!d.set;\n}","tryCatchPattern":null,"preventionTips":["Import/install the polyfill before any lockdown or global freeze (e.g. before SES lockdown()).","Never define globals as non-configurable/non-writable before loading polyfills.","Dedupe @rxjs/observable-polyfill in bundler resolutions to avoid conflicting installs.","In hardened sandboxes, consume the module's exports instead of installing globals."],"tags":["polyfill-installation","global-this","property-descriptor","lockdown","initialization"],"backgroundTag":"polyfill-property-installation-conflict","analyzedSha":"54796b38a57e6309f9861e174737479bb3f63f61","analyzedAt":"2026-08-28T10:21:27.410Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}