Reattached to the wrong terminal
See original GitHub issueI just reloaded a window with my vscode-jupyter
repo open, and it attached to a terminal which is already open in my vscode
repo, so now this terminal is open in two windows:
The right window is the window that originally owned this terminal
One thing about this terminal is that its cwd is some other folder outside of both workspaces, if that matters.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:46 (40 by maintainers)
Top Results From Across the Web
I Accidentally Crossed the Jumper Cables, This Is What ...
A portion of a grille on a minivan melted after jumper cables that were attached to the wrong battery terminals melted | HJ...
Read more >Help! Removed the wrong terminal and sparks flew...am I ...
I was trying to clean the battery terminals but I didn't realize I had to loosen the positive terminal clamps first. I stared...
Read more >replaced the starter. went to connect the negative batter...
Q: replaced the starter. went to connect the negative battery terminal, the starter made a whirring sound and sparked at terminal. asked by....
Read more >What happens if you connect your battery backwards?
The owner also said his alternator was fried as a resultSupport my Channel here! https://www.patreon.com/dannyjohnson.
Read more >How To Reboot Your Car ~ Battery VooDoo - YouTube
An error occurred while retrieving sharing information. Please try again later. 0:00. 0:00 / 9:44• Live. •. •. Scroll for details ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I figured this out. What a journey! Here is the fairly reliable repro:
./scripts/code
a
andb
a
andb
and close all terminals./scripts/code
a
: Open 3 terminals and type “a”, “b”, “c” into them respectively, this helps identify them to ensure they’re in the correct order laterb
: Open 3 terminals and type “d”, “e”, “f” into them respectively./scripts/code
a
andb
should revive the processes and have all terminals in the correct order they were created (this works)a
and windowb
at the same timea
andb
should revive the processes and have all terminals in the correct order they were created 🐛Note that this is a timing issue and has a chance to not reproduce the problem.
This is what is meant to happen when exiting and restarting the pty host process. Terminal processes are revived (aka. re-created) and their actual pty IDs for this pty host process are mapped to, starting at 1. Notice below how the new IDs start from 1, they just represent the order they are created in which shouldn’t matter when reviving.
After that, when reloading windows, terminal processes do not get revived but reconnected to. So an
undefined
mapping is expected:What is happening and what is causing this bug as well as a related issue[^1] is that the revived pty ID is cached, so if reloading happens to use a
newId
that is mapped to a different pty ID in_revivedPtyIdMap
, it will reconnect to that one instead:The above results in:
Then on reload the pty ID mapping occurs instead of being undefined, which causes a reconnect to the wrong pty.
So in the above they get re-mapped, shuffling the order within a window and potentially connecting to a different window’s ptys:
[^1]: The folder’s terminals may not get restored at with the warning “Couldn’t get layout info, a terminal was probably disconnected” in the pty host output channel. This started happening due to one of the previous workarounds to prevent 2 windows attaching to the same pty.
Yep, it’s not working atm for remote terminals, so: