Could not load worker
See original GitHub issueProblem
Couldn’t load worker, JSON syntax validation doesn’t work. I see Could not load worker
warning in the browser console.
Also, I tried to import the json worker
import "ace-builds/src-noconflict/worker-json";
and got the error
TypeError: Cannot read property 'window' of undefined
Sample code to reproduce the issue
import React from "react";
import ReactDOM from "react-dom";
import AceEditor from "react-ace";
import "ace-builds/src-noconflict/ace";
import "ace-builds/src-noconflict/mode-json";
import "ace-builds/src-noconflict/theme-github";
let text =
'{\n "id": 0,\n ' +
'"script": """\n function add(x, y) {\n return x + y;\n }\n add(1, 2);\n """' +
',\n "descr": "add two numbers"\n}';
function App() {
return (
<div className="App">
<h1>Code Editor Demo</h1>
<AceEditor
mode="json"
theme="github"
onChange={(value, stat) => {
console.log("onChange", value, stat);
}}
value={text}
name="UNIQUE_ID_OF_DIV"
editorProps={{ $blockScrolling: true }}
/>
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
References
Codesandbox https://codesandbox.io/embed/ace-worker-3-vrr68
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:30 (1 by maintainers)
Top Results From Across the Web
Chrome Extension - Ace Editor worker fails to load
The reason it fails is due to a Content Security Policy error in the worker loader, which uses importScripts : importScripts('chrome-extension: ...
Read more >Web worker fails to load in sandboxed iframe with Firefox 45
We see this behavior when using pdf.js to display PDF's inside a sandboxed iframe. Actual results: PDF.js fails to load the web worker...
Read more >worker-loader - webpack - JS.ORG
Even downloads from the webpack-dev-server could be blocked. There are two workarounds: Firstly, you can inline the worker as a blob instead of...
Read more >How to Solve the Chunk Load Error in JavaScript
If you observe that the files are not being served correctly or the URLs are incorrect, it should be straightforward to resolve this...
Read more >Web Workers
I was trying to use web workers in a vue cli context. For some reasons, it would not load the worker file without...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to either include the webpack-resolver
or configure the url for each mode separately
both methods require “file-loader”
also react-ace tries to load brace if ace is not already imported so ace-builds needs to be imported before react-ace.
setOptions={{ useWorker: false }}
works for me. Thanks @khoomeister