{"record":{"id":"fd3b1574f3cd4362","repo":"ajaxorg/ace","slug":"could-not-load-worker","errorCode":null,"errorMessage":"Could not load worker","messagePattern":"Could not load worker","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edit_session.js","lineNumber":1051,"sourceCode":"            this.$options.wrapMethod.set.call(this, this.$wrapMethod);\n            this.$setFolding(mode.foldingRules);\n            this.bgTokenizer.start(0);\n            this._emit(\"changeMode\", {oldMode: oldMode, mode: mode});\n        }\n    }\n\n    $stopWorker() {\n        if (this.$worker) {\n            this.$worker.terminate();\n            this.$worker = null;\n        }\n    }\n\n    $startWorker() {\n        try {\n            this.$worker = this.$mode.createWorker(this);\n        } catch (e) {\n            config.warn(\"Could not load worker\", e);\n            this.$worker = null;\n        }\n    }\n\n    /**\n     * Returns the current text mode.\n     * @returns {TextMode} The current text mode\n     **/\n    getMode() {\n        return this.$mode;\n    }\n\n    /**\n     * This function sets the scroll top value. It also emits the `'changeScrollTop'` event.\n     * @param {Number} scrollTop The new scroll top value\n     **/\n    setScrollTop(scrollTop) {\n        // TODO: should we force integer lineheight instead? scrollTop = Math.round(scrollTop);","sourceCodeStart":1033,"sourceCodeEnd":1069,"githubUrl":"https://github.com/ajaxorg/ace/blob/2c1eddc392eb92cf222a4478f1893d2b2c354fb0/src/edit_session.js#L1033-L1069","documentation":"config.warn('Could not load worker', e) fires when $startWorker's call to mode.createWorker(session) throws — i.e., the mode's background worker (syntax checker/highlighter worker) failed to spawn. The session continues in degraded mode with $worker = null; this is a logged warning, not a thrown exception.","triggerScenarios":"Loading Ace from a CDN/cross-origin origin where worker scripts can't be fetched, a missing worker JS file (e.g., worker-javascript.js 404), mismatched ace versions between main lib and workers, or restrictive CSP without worker-src.","commonSituations":"Self-hosting ace with an incomplete copy of the lib directory; bundlers that fail to emit the worker chunk; file:// or sandboxed iframes blocking Web Workers; old mode files against a newer ace core.","solutions":["Include the full ace worker files (e.g., worker-javascript.js) alongside the core, matching your ace version","If self-hosting, set ace.config.set('workerPath', '/path/to/ace/build') to the directory containing worker scripts","Check the second argument of the warning in console for the underlying error (404, CSP, SecurityError)","Use a single-file bundle like ace.js from the build which inlines workers, or disable the worker with mode-specific options if linting isn't needed"],"exampleFix":"// before\nace.config.set('basePath', '/js/ace'); // workers missing from /js/ace\n// after\nace.config.set('basePath', '/js/ace');\nace.config.set('workerPath', '/js/ace'); // dir containing worker-javascript.js etc.","handlingStrategy":"fallback","validationCode":"// ensure workers are reachable before creating the editor\nfetch(ace.config.get('workerPath') + '/worker-javascript.js', { method: 'HEAD' })\n  .catch(function() { console.warn('workers unavailable; running without lint worker'); });","typeGuard":null,"tryCatchPattern":"// ace catches internally and continues ($worker = null); on your side:\neditor.session.on('changeAnnotation', function() {\n  if (editor.session.$worker === null) console.info('no worker; annotations limited');\n});","preventionTips":["Ship the full ace build directory including all worker-*.js files","Set ace.config.set('workerPath', ...) when workers aren't adjacent to the core","Add CSP worker-src 'self' (or blob:) if you use a strict CSP","Use the single-file ace build that inlines workers when deploy layout is uncertain","Note file:// origins can block workers — serve over http"],"tags":["web-worker","mode","configuration","loading"],"backgroundTag":"worker-load-failed","analyzedSha":"2c1eddc392eb92cf222a4478f1893d2b2c354fb0","analyzedAt":"2026-08-30T00:39:52.222Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}