@@ -76,7 +76,6 @@ class DocumentLinter {
76
76
parser = process . createDocumentForVSCode ( ) ;
77
77
} catch ( e ) {
78
78
if ( e instanceof ProcessCrashed ) {
79
- this . _documentProcessManager . processCrashed ( process ) ;
80
79
throw new LintingCrashed ( e ) ;
81
80
} else {
82
81
throw e ;
@@ -121,7 +120,6 @@ class DocumentLinter {
121
120
this . _parser . dispose ( ) ;
122
121
} catch ( e ) {
123
122
if ( e instanceof ProcessCrashed ) {
124
- this . _documentProcessManager . processCrashed ( this . _parser . process ) ;
125
123
// Ignore.
126
124
} else {
127
125
throw e ;
@@ -209,7 +207,6 @@ class DocumentLinter {
209
207
} catch ( e ) {
210
208
// END CRITICAL SECTION (no awaiting above)
211
209
if ( e instanceof ProcessCrashed ) {
212
- this . _documentProcessManager . processCrashed ( this . _parser . process ) ;
213
210
await this . _recoverFromCrashAsync ( e ) ;
214
211
} else {
215
212
throw e ;
@@ -253,7 +250,6 @@ class DocumentLinter {
253
250
this . _document . setDiagnostics ( diags ) ;
254
251
} catch ( e ) {
255
252
if ( e instanceof ProcessCrashed ) {
256
- this . _documentProcessManager . processCrashed ( this . _parser . process ) ;
257
253
await this . _recoverFromCrashAsync ( e ) ;
258
254
} else {
259
255
throw e ;
@@ -295,7 +291,6 @@ class DocumentLinter {
295
291
this . _parserPromise = null ;
296
292
this . _state = DocumentLinterState . NO_PARSER ;
297
293
if ( e instanceof ProcessCrashed ) {
298
- this . _documentProcessManager . processCrashed ( process ) ;
299
294
throw new LintingCrashed ( e ) ;
300
295
} else {
301
296
throw e ;
@@ -315,24 +310,12 @@ class DocumentProcessManager {
315
310
this . _processFactoryPromise = createProcessFactoryAsync ( ) ;
316
311
this . _processesCreated = 0 ;
317
312
this . _processPromise = null ;
318
- this . _process = null ;
319
- }
320
-
321
- processCrashed ( process ) {
322
- if ( ! ( process instanceof Process ) ) {
323
- throw new TypeError ( `Expected Process, but got ${ process } ` ) ;
324
- }
325
- if ( this . _process === process ) {
326
- this . _process = null ;
327
- this . _processPromise = null ;
328
- }
329
313
}
330
314
331
315
async createNewProcessAsync ( ) {
332
316
let processFactory = await this . _processFactoryPromise ;
333
317
let process = await processFactory . createProcessAsync ( ) ;
334
318
this . _processesCreated += 1 ;
335
- this . _process = process ;
336
319
return process ;
337
320
}
338
321
@@ -341,13 +324,17 @@ class DocumentProcessManager {
341
324
if ( this . _processPromise === null ) {
342
325
this . _processPromise = this . createNewProcessAsync ( ) ;
343
326
// END CRITICAL SECTION (no awaiting above)
327
+ } else {
328
+ // END CRITICAL SECTION (no awaiting above)
344
329
}
345
- return await this . _processPromise ;
346
- }
347
-
348
- _forgetCurrentProcess ( ) {
349
- this . _process = null ;
350
- this . _processPromise = null ;
330
+ let process = await this . _processPromise ;
331
+ // BEGIN CRITICAL SECTION (no awaiting below)
332
+ while ( process . isTainted ( ) ) {
333
+ this . _processPromise = this . createNewProcessAsync ( ) ;
334
+ // END CRITICAL SECTION (no awaiting above)
335
+ process = await this . _processPromise ;
336
+ }
337
+ return process ;
351
338
}
352
339
353
340
// For testing only.
@@ -501,6 +488,10 @@ class Process {
501
488
this . _webDemoSetText = wrap ( "qljs_web_demo_set_text" ) ;
502
489
}
503
490
491
+ isTainted ( ) {
492
+ return this . _crashedException !== null ;
493
+ }
494
+
504
495
toString ( ) {
505
496
return `Process(id=${ this . _idForDebugging } )` ;
506
497
}
0 commit comments