question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

errors.js:12 Uncaught Error: Could not find source file: 'inmemory://model/1'.

See original GitHub issue

Probably related to #1840? I’m using Svelte and not React, but it doesn’t matter. This is about quickly disposing an editor after creating it. E.g. in my app if I click very fast the component is unmounted very quickly, causing a call to dispose to clean the component up, which will spit out the error in the console.

monaco-editor version: 0.20.0 Browser: Chrome 80.0.3987.106 OS: Ubuntu 19.10 Playground code that reproduces the issue:

Paste into playground and hit “Run” > 1 times.

let editor = monaco.editor.create(document.getElementById('container'), {
  value: '_',
  language: 'javascript'
});

requestIdleCallback(function() {
  editor.dispose();
});

Minimal example also here: https://github.com/Prinzhorn/monaco-could-not-find-source-file

In Chrome I get this error consistently every single time (in Playground I sometimes need to “Run” twice)

Selection_589

errors.js:12 Uncaught Error: Could not find source file: 'inmemory://model/1'.

Error: Could not find source file: 'inmemory://model/1'.
    at y (ts.worker.js:82)
    at Object.getCodeFixesAtPosition (ts.worker.js:82)
    at t.getCodeFixesAtPosition (ts.worker.js:86)
    at n.fmr (ts.worker.js:74)
    at e._handleMessage (ts.worker.js:15)
    at Object.handleMessage (ts.worker.js:15)
    at r._handleMessage (ts.worker.js:15)
    at r.handleMessage (ts.worker.js:15)
    at e.onmessage (ts.worker.js:15)
    at self.onmessage (ts.worker.js:76)
    at errors.js:12

(anonymous) @ errors.js:12
setTimeout (async)
ErrorHandler.unexpectedErrorHandler @ errors.js:10
ErrorHandler.onUnexpectedExternalError  @ errors.js:29
onUnexpectedExternalError @ errors.js:45
(anonymous) @ codeAction.js:142
step  @ codeAction.js:49
(anonymous) @ codeAction.js:30
rejected  @ codeAction.js:22
Promise.then (async)
step  @ codeAction.js:23
(anonymous) @ codeAction.js:24
__awaiter @ codeAction.js:20
(anonymous) @ codeAction.js:123
getCodeActions  @ codeAction.js:123
(anonymous) @ codeActionModel.js:188
createCancelablePromise @ async.js:13
(anonymous) @ codeActionModel.js:188
CodeActionOracle._createEventAndSignalChange  @ codeActionModel.js:125
CodeActionOracle.trigger  @ codeActionModel.js:43
CodeActionModel._update @ codeActionModel.js:194
(anonymous) @ codeActionModel.js:159
Emitter.fire  @ event.js:509
LanguageFeatureRegistry.register  @ languageFeatureRegistry.js:43
registerCodeActionProvider  @ standaloneLanguages.js:289
setupMode @ languageFeatures.js:913
setupJavaScript @ languageFeatures.js:913
(anonymous) @ monaco.contribution.js:203
Promise.then (async)
LazyPromise.then  @ bundle-loader.js:77
(anonymous) @ monaco.contribution.js:203
(anonymous) @ standaloneLanguages.js:42
Emitter.fire  @ event.js:509
ModeServiceImpl._getOrCreateMode  @ modeServiceImpl.js:105
ModeServiceImpl._createModeAndGetLanguageIdentifier @ modeServiceImpl.js:93
(anonymous) @ modeServiceImpl.js:80
LanguageSelection @ modeServiceImpl.js:31
ModeServiceImpl.create  @ modeServiceImpl.js:78
createModel @ standaloneEditor.js:101
StandaloneEditor  @ standaloneCodeEditor.js:192
(anonymous) @ standaloneEditor.js:58
withAllStandaloneServices @ standaloneEditor.js:45
create  @ standaloneEditor.js:57
parcelRequire.index.js.monaco-editor  @ index.js:21
newRequire  @ monaco-could-not-fin…file.e31bb0bc.js:47
(anonymous) @ monaco-could-not-fin…file.e31bb0bc.js:81
(anonymous) @ monaco-could-not-fin…ile.e31bb0bc.js:120

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Javeycommented, Apr 20, 2020

The same with me. When we quickly dispose the eidtor, the worker is still alive.

0reactions
alexdimacommented, Sep 18, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest: Could not find source file error - DEV Community ‍ ‍
Occasionally I've been seeing the following error when running my Jest test suite. The source files always exist in the right location -...
Read more >
TS-Node: Could not find sourceFile - Stack Overflow
I have a feeling this has to do with circular dependencies. Especially with the answer from @Brenne saying:.
Read more >
Could not find source file - Peter Prins
Description. When running my Jest test scripts I encountered the following error: Error. Solution.
Read more >
Fatal error: could not open source file "_gen.c" - TI E2E
This error occurs when the compiler cannot find the the source file. Please make sure the file indeed exists and is located in...
Read more >
How to fix "Source file could not be read" error on Firefox?
Methods to solve “Could not be saved because the source file could not be read” error · Method 1. Check Internet connection ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found