diff --git a/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.ts b/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.ts index 15afd968006e15..fc7f3e7fb31065 100644 --- a/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.ts +++ b/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.ts @@ -378,14 +378,23 @@ export class TextMateTokenizationFeature extends Disposable implements ITextMate private _getVSCodeOniguruma(): Promise { if (!this._vscodeOniguruma) { this._vscodeOniguruma = (async () => { - const [vscodeOniguruma, wasm] = await Promise.all([importAMDNodeModule('vscode-oniguruma', 'release/main.js'), this._loadVSCodeOnigurumaWASM()]); - await vscodeOniguruma.loadWASM({ - data: wasm, - print: (str: string) => { - this._debugModePrintFunc(str); - } - }); - return vscodeOniguruma; + try { + const [vscodeOniguruma, wasm] = await Promise.all([importAMDNodeModule('vscode-oniguruma', 'release/main.js'), this._loadVSCodeOnigurumaWASM()]); + await vscodeOniguruma.loadWASM({ + data: wasm, + print: (str: string) => { + this._debugModePrintFunc(str); + } + }); + return vscodeOniguruma; + } catch (err) { + // Do not cache a rejected promise: loading the WASM can fail with a transient + // error (e.g. "Failed to fetch" while the window is being torn down). Caching + // the rejection would permanently break tokenization for the rest of the + // session and cause the same error to be re-reported for every language. + this._vscodeOniguruma = null; + throw err; + } })(); } return this._vscodeOniguruma;