Skip to content

Commit 5c7bf1f

Browse files
vs-code-engineering[bot]Copilotalexdima
authored
fix: don't cache rejected oniguruma WASM load promise (fixes #326825) (#326830)
* fix: don't cache rejected oniguruma WASM load promise (fixes #326825) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Attestation commit --------- Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Alex Dima <alexdima@microsoft.com>
1 parent f3fa55c commit 5c7bf1f

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

‎src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.ts‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,23 @@ export class TextMateTokenizationFeature extends Disposable implements ITextMate
378378
private _getVSCodeOniguruma(): Promise<typeof import('vscode-oniguruma')> {
379379
if (!this._vscodeOniguruma) {
380380
this._vscodeOniguruma = (async () => {
381-
const [vscodeOniguruma, wasm] = await Promise.all([importAMDNodeModule<typeof import('vscode-oniguruma')>('vscode-oniguruma', 'release/main.js'), this._loadVSCodeOnigurumaWASM()]);
382-
await vscodeOniguruma.loadWASM({
383-
data: wasm,
384-
print: (str: string) => {
385-
this._debugModePrintFunc(str);
386-
}
387-
});
388-
return vscodeOniguruma;
381+
try {
382+
const [vscodeOniguruma, wasm] = await Promise.all([importAMDNodeModule<typeof import('vscode-oniguruma')>('vscode-oniguruma', 'release/main.js'), this._loadVSCodeOnigurumaWASM()]);
383+
await vscodeOniguruma.loadWASM({
384+
data: wasm,
385+
print: (str: string) => {
386+
this._debugModePrintFunc(str);
387+
}
388+
});
389+
return vscodeOniguruma;
390+
} catch (err) {
391+
// Do not cache a rejected promise: loading the WASM can fail with a transient
392+
// error (e.g. "Failed to fetch" while the window is being torn down). Caching
393+
// the rejection would permanently break tokenization for the rest of the
394+
// session and cause the same error to be re-reported for every language.
395+
this._vscodeOniguruma = null;
396+
throw err;
397+
}
389398
})();
390399
}
391400
return this._vscodeOniguruma;

0 commit comments

Comments
 (0)