@@ -50,6 +50,7 @@ import { ILifecycleService, ShutdownReason, WillShutdownEvent } from 'vs/workben
50
50
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService' ;
51
51
import { ACTIVE_GROUP , SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
52
52
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
53
+ import { ILogService } from 'vs/platform/log/common/log' ;
53
54
54
55
export class TerminalService implements ITerminalService {
55
56
declare _serviceBrand : undefined ;
@@ -160,6 +161,7 @@ export class TerminalService implements ITerminalService {
160
161
@IContextKeyService private _contextKeyService : IContextKeyService ,
161
162
@ILabelService labelService : ILabelService ,
162
163
@ILifecycleService lifecycleService : ILifecycleService ,
164
+ @ILogService private readonly _logService : ILogService ,
163
165
@IDialogService private _dialogService : IDialogService ,
164
166
@IInstantiationService private _instantiationService : IInstantiationService ,
165
167
@IRemoteAgentService private _remoteAgentService : IRemoteAgentService ,
@@ -585,22 +587,27 @@ export class TerminalService implements ITerminalService {
585
587
586
588
// Persist terminal _buffer state_, note that even if this happens the dirty terminal prompt
587
589
// still shows as that cannot be revived
588
- this . _shutdownWindowCount = await this . _nativeDelegate ?. getWindowCount ( ) ;
589
- const shouldReviveProcesses = this . _shouldReviveProcesses ( reason ) ;
590
- if ( shouldReviveProcesses ) {
591
- await this . _primaryOffProcessTerminalService ?. persistTerminalState ( ) ;
592
- }
593
-
594
- // Persist terminal _processes_
595
- const shouldPersistProcesses = this . _configHelper . config . enablePersistentSessions && reason === ShutdownReason . RELOAD ;
596
- if ( ! shouldPersistProcesses ) {
597
- const hasDirtyInstances = (
598
- ( this . configHelper . config . confirmOnExit === 'always' && this . instances . length > 0 ) ||
599
- ( this . configHelper . config . confirmOnExit === 'hasChildProcesses' && this . instances . some ( e => e . hasChildProcesses ) )
600
- ) ;
601
- if ( hasDirtyInstances ) {
602
- return this . _onBeforeShutdownConfirmation ( reason ) ;
590
+ try {
591
+ this . _shutdownWindowCount = await this . _nativeDelegate ?. getWindowCount ( ) ;
592
+ const shouldReviveProcesses = this . _shouldReviveProcesses ( reason ) ;
593
+ if ( shouldReviveProcesses ) {
594
+ await this . _primaryOffProcessTerminalService ?. persistTerminalState ( ) ;
595
+ }
596
+
597
+ // Persist terminal _processes_
598
+ const shouldPersistProcesses = this . _configHelper . config . enablePersistentSessions && reason === ShutdownReason . RELOAD ;
599
+ if ( ! shouldPersistProcesses ) {
600
+ const hasDirtyInstances = (
601
+ ( this . configHelper . config . confirmOnExit === 'always' && this . instances . length > 0 ) ||
602
+ ( this . configHelper . config . confirmOnExit === 'hasChildProcesses' && this . instances . some ( e => e . hasChildProcesses ) )
603
+ ) ;
604
+ if ( hasDirtyInstances ) {
605
+ return this . _onBeforeShutdownConfirmation ( reason ) ;
606
+ }
603
607
}
608
+ } catch ( err : unknown ) {
609
+ // Swallow as exceptions should not cause a veto to prevent shutdown
610
+ this . _logService . warn ( 'Exception occurred during terminal shutdown' , err ) ;
604
611
}
605
612
606
613
this . _isShuttingDown = true ;
0 commit comments