Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal reconnection isn't working #187282

Closed
meganrogge opened this issue Jul 7, 2023 · 7 comments · Fixed by #187285
Closed

terminal reconnection isn't working #187282

meganrogge opened this issue Jul 7, 2023 · 7 comments · Fixed by #187285
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders regression Something that used to work is now broken terminal-persistence Relating to process reconnection or process revive verified Verification succeeded
Milestone

Comments

@meganrogge
Copy link
Contributor

  1. create some terminals and type in them
  2. reload the window or restart VS Code
  3. 🐛 they don't persist

Started happening in OSS on Wednesday July 5th

@meganrogge meganrogge added bug Issue identified by VS Code Team member as probable bug regression Something that used to work is now broken terminal-persistence Relating to process reconnection or process revive labels Jul 7, 2023
@meganrogge meganrogge added this to the July 2023 milestone Jul 7, 2023
@meganrogge
Copy link
Contributor Author

layoutInfo is undefined
Screenshot 2023-07-07 at 9 09 16 AM

@meganrogge
Copy link
Contributor Author

it gets set to undefined
Screenshot 2023-07-07 at 9 10 01 AM

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2023

@meganrogge that's the return value (see [RPC Response])

@meganrogge
Copy link
Contributor Author

yes, true. but the getTerminalLayoutInfo call returns undefined so it's getting reset somewhere. not via saveState
Screenshot 2023-07-07 at 9 18 06 AM

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2023

I'm on to the cause... The process is getting killed after detaching on reload, so reconnect breaks:

2023-07-07 09:19:10.623 [trace] [RPC Request] PtyService#setTerminalLayoutInfo({"workspaceId":"199b212e1c8d1b0f08747c4773181855","tabs":[{"isActive":false,"activePersistentProcessId":3,"terminals":[{"relativeSize":1,"terminal":3}]},{"isActive":true,"activePersistentProcessId":4,"terminals":[{"relativeSize":1,"terminal":4}]}]})
2023-07-07 09:19:10.624 [trace] [RPC Response] PtyService#setTerminalLayoutInfo undefined
2023-07-07 09:19:10.869 [trace] [RPC Request] PtyService#input(4, "b")
2023-07-07 09:19:10.869 [trace] node-pty.IPty#write b
2023-07-07 09:19:10.869 [trace] [RPC Response] PtyService#input undefined
2023-07-07 09:19:10.869 [trace] node-pty.IPty#onData b
2023-07-07 09:19:10.876 [trace] [RPC Event] PtyService#_onProcessData.fire({"id":4,"event":"b"})
2023-07-07 09:19:11.064 [trace] [RPC Request] PtyService#input(4, "c")
2023-07-07 09:19:11.064 [trace] node-pty.IPty#write c
2023-07-07 09:19:11.064 [trace] [RPC Response] PtyService#input undefined
2023-07-07 09:19:11.064 [trace] node-pty.IPty#onData c
2023-07-07 09:19:11.069 [trace] [RPC Event] PtyService#_onProcessData.fire({"id":4,"event":"c"})
2023-07-07 09:19:11.406 [info] Persistent process "1": The reconnection grace time of 1m has expired, shutting down pid "3210"
2023-07-07 09:19:11.407 [trace] TerminalProcess#shutdown 
    at TerminalProcess.shutdown (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:377:68)
    at PersistentTerminalProcess.shutdown (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:762:42)
    at ProcessTimeRunOnceScheduler.runner (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:678:22)
    at ProcessTimeRunOnceScheduler.onInterval (/Users/daimms/dev/microsoft/vscode/out/vs/base/common/async.js:784:26)
    at listOnTimeout (node:internal/timers:559:17)
    at process.processTimers (node:internal/timers:502:7)
2023-07-07 09:19:11.407 [trace] node-pty.IPty#kill
2023-07-07 09:19:11.408 [trace] [RPC Event] PtyService#_onProcessExit.fire({"id":1,"event":0})
2023-07-07 09:19:11.408 [info] Persistent process "2": The reconnection grace time of 1m has expired, shutting down pid "3211"
2023-07-07 09:19:11.408 [trace] TerminalProcess#shutdown 
    at TerminalProcess.shutdown (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:377:68)
    at PersistentTerminalProcess.shutdown (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:762:42)
    at ProcessTimeRunOnceScheduler.runner (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:678:22)
    at ProcessTimeRunOnceScheduler.onInterval (/Users/daimms/dev/microsoft/vscode/out/vs/base/common/async.js:784:26)
    at listOnTimeout (node:internal/timers:559:17)
    at process.processTimers (node:internal/timers:502:7)
2023-07-07 09:19:11.408 [trace] node-pty.IPty#kill
2023-07-07 09:19:11.409 [trace] [RPC Event] PtyService#_onProcessExit.fire({"id":2,"event":0})
2023-07-07 09:19:11.409 [trace] node-pty.IPty#onData �[?2004l
2023-07-07 09:19:11.409 [trace] node-pty.IPty#onData �[?2004l
2023-07-07 09:19:11.409 [trace] node-pty.IPty#onData �[?2004h�[?2004l


2023-07-07 09:19:11.409 [trace] node-pty.IPty#onData �[?2004h�[?2004l


2023-07-07 09:19:11.412 [trace] TerminalProcess#_queueProcessExit 
    at TerminalProcess._queueProcessExit (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:314:77)
    at /Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:285:22
    at EventEmitter2.fire (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/eventEmitter2.js:41:22)
    at PipeSocket.<anonymous> (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/terminal.js:93:76)
    at PipeSocket.emit (node:events:513:28)
    at Terminal.emit (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/terminal.js:155:34)
    at PipeSocket.<anonymous> (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/unixTerminal.js:98:27)
    at Object.onceWrapper (node:events:628:26)
    at PipeSocket.emit (node:events:525:35)
    at Pipe.<anonymous> (node:net:757:14)
2023-07-07 09:19:11.412 [trace] TerminalProcess#_queueProcessExit 
    at TerminalProcess._queueProcessExit (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:314:77)
    at /Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:285:22
    at EventEmitter2.fire (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/eventEmitter2.js:41:22)
    at PipeSocket.<anonymous> (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/terminal.js:93:76)
    at PipeSocket.emit (node:events:513:28)
    at Terminal.emit (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/terminal.js:155:34)
    at PipeSocket.<anonymous> (/Users/daimms/dev/microsoft/vscode/node_modules/node-pty/lib/unixTerminal.js:98:27)
    at Object.onceWrapper (node:events:628:26)
    at PipeSocket.emit (node:events:525:35)
    at Pipe.<anonymous> (node:net:757:14)
2023-07-07 09:19:54.405 [trace] [RPC Request] PtyService#detachFromProcess(3, false)
2023-07-07 09:19:54.406 [trace] TerminalProcess#shutdown 
    at TerminalProcess.shutdown (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/terminalProcess.js:377:68)
    at PersistentTerminalProcess.shutdown (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:762:42)
    at PersistentTerminalProcess.detach (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:720:22)
    at PtyService.detachFromProcess (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:245:43)
    at descriptor.<computed> (/Users/daimms/dev/microsoft/vscode/out/vs/platform/terminal/node/ptyService.js:30:35)
    at Object.call (/Users/daimms/dev/microsoft/vscode/out/vs/base/parts/ipc/common/ipc.js:850:39)
    at ChannelServer.onPromise (/Users/daimms/dev/microsoft/vscode/out/vs/base/parts/ipc/common/ipc.js:287:35)
    at ChannelServer.onRawMessage (/Users/daimms/dev/microsoft/vscode/out/vs/base/parts/ipc/common/ipc.js:266:33)
    at UniqueContainer.value (/Users/daimms/dev/microsoft/vscode/out/vs/base/parts/ipc/common/ipc.js:217:73)
    at Emitter._deliver (/Users/daimms/dev/microsoft/vscode/out/vs/base/common/event.js:832:26)
    at Emitter._deliverQueue (/Users/daimms/dev/microsoft/vscode/out/vs/base/common/event.js:843:22)
    at Emitter.fire (/Users/daimms/dev/microsoft/vscode/out/vs/base/common/event.js:866:22)
    at MessagePortMain.fn (/Users/daimms/dev/microsoft/vscode/out/vs/base/common/event.js:413:44)
    at MessagePortMain.emit (node:events:513:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)
2023-07-07 09:19:54.406 [trace] node-pty.IPty#kill
2023-07-07 09:19:54.406 [trace] [RPC Event] PtyService#_onProcessExit.fire({"id":3,"event":0})
2023-07-07 09:19:54.406 [trace] [RPC Response] PtyService#detachFromProcess undefined
2023-07-07 09:19:54.406 [trace] [RPC Request] PtyService#detachFromProcess(4, false)
2023-07-07 09:19:54.406 [trace] [RPC Response] PtyService#detachFromProcess undefined

Revive after restart is working for me.

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2023

Ah found it:

2023-07-07 09:28:56.963 [trace] [RPC Request] PtyService#getTerminalLayoutInfo({"workspaceId":"199b212e1c8d1b0f08747c4773181855"})
2023-07-07 09:28:56.964 [info] Expanding terminal instance, old id 199b212e1c8d1b0f08747c4773181855-3 -> new id undefined
2023-07-07 09:28:56.964 [warning] Couldn't get layout info, a terminal was probably disconnected Could not find pty on pty host
2023-07-07 09:28:56.964 [info] Reattach to wrong terminal debug info - layout info by id {"relativeSize":1,"terminal":3}
2023-07-07 09:28:56.964 [info] Reattach to wrong terminal debug info - _revivePtyIdMap []

One of the sanity checks I put in place that didn't actually help fix the reattach problem caused it

Investigating...

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2023

Parsed state is null so reconnect stops here:

const parsed = this._deserializeTerminalState(serializedState);

@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 7, 2023
@DonJayamanne DonJayamanne added the verified Verification succeeded label Jul 27, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders regression Something that used to work is now broken terminal-persistence Relating to process reconnection or process revive verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants