indexeddbshim / indexeddbshim/IndexedDBShim
Browser error - Cannot assign to read only property 'window' of object '#<Window>'
- Dominant language
- JavaScript
- Stars
- 979
- Forks
- 191
- Avg merge
- 55m
- Merged PRs (30d)
- 2
Description
I am trying to use `IndexedDbShim` with a react application. I am using [create-react-app](https://github.com/facebook/create-react-app) and this is the main app `index.js` file that runs before everything else:
```
import '@babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import { toJS } from 'mobx';
import AsyncLoad from './common/components/AsyncComponent';
import { setGlobalVars } from 'indexeddbshim';
global.window = global; // We'll allow ourselves to use `window.indexedDB` or `indexedDB` as a global
setGlobalVars(); // See signature below
...
// unrelated code continues here
```
I am getting the following error in the console:
> Uncaught TypeError: Cannot assign to read only property 'window' of object '#'
> at Object. (index.js:10)
> at Object../src/index.js (index.js:35)
> at __webpack_require__ (bootstrap 8babaf20081f9cc7653e:698)
> at fn (bootstrap 8babaf20081f9cc7653e:111)
> at Object.0 (index.js:35)
> at __webpack_require__ (bootstrap 8babaf20081f9cc7653e:698)
> at bootstrap 8babaf20081f9cc7653e:796
> at bootstrap 8babaf20081f9cc7653e:796
Is there a known workaround for this? Or is there a polyfill version that ships as a single file that I can use as a static dependencies (webpack bundles my `node_modules` code so I cannot just include the npm install in my static html files).
Thanks for the help.
Contributor guide
Research direction
Start with the reported index.js entry point and the global.window = global / setGlobalVars() sequence. Reproduce the error in the stated create-react-app setup, then investigate whether a supported initialization path or static bundled dependency avoids it. Done means the app initializes without the read-only window error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- database, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100