-
Notifications
You must be signed in to change notification settings - Fork 7
Fix attach resize #29
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So says the warning emitted by the websocket library every time we try to set StatusAbnormalClosure.
Previously we would spawn the daemon via -Dm then attach with -x once it was ready. This had a flaw: the daemon starts with a hardcoded 24x80 size and when the attach comes in it resizes and leaves a bunch of confusing whitespace above your prompt. Now we skip the daemon spawn and go straight for the attach but with the addition of -RR which lets screen spawn the daemon for us if it does not yet exist. Consequences: 1. We can only allow one attach at a time because screen has no problem creating multiple daemons with the same name. 2. IDs cannot overlap since screen will do partial matching when we do not include the PID which we no longer have. 3. We do not know when the daemon exits so cleanup only happens on the timeout. 4. We have to kill the session by sending the quit command through screen. When we do this it is possible the session is already dead. 5. If the daemon exits and the user reconnects before the timeout the daemon will be respawned all while the Go program remains blissfully unaware assuming it has been up this whole time. Does not change anything in practice, just a bit different in terms of underlying architecture. In some ways this new architecture is actually simpler with roughly the same functionality but it does not support concurrent attaches and has a greater danger of desyncing from screen's own state.
bcd5de4 to
2610e45
Compare
Member
Author
|
This can be experimented with here: https://github.com/coder/v1/pull/13400 |
spikecurtis
reviewed
Dec 8, 2022
Contributor
spikecurtis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, but I have some concerns about leaking screen sessions or the goroutines that are meant to stop them.
1e3e3c9 to
b088440
Compare
Hopefully makes it a bit easier to see what is going on.
Trying to figure out why a session is prematurely closing. To do this I am setting the error via setState (so I can add the reason at the close call site) rather than checking for a nil error and returning it in the Attach. Alternatively I was thinking of adding a reason arg to setState but only the close state needs a reason and ultimately it was transformed into the error anyway so might as well do it earlier and skip a step.
e76f34a to
6391e65
Compare
This was canceling while the reconnect test was running.
54778d7 to
698c327
Compare
Having too many seems to be causing some to exit unexpectedly.
Member
Author
|
I think I got all the flakes:
|
spikecurtis
approved these changes
Dec 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we would spawn the daemon via -Dm then attach with -x once it
was ready. This had a flaw: the daemon starts with a hardcoded 24x80
size and when the attach comes in it resizes and leaves a bunch of
confusing whitespace above your prompt.
Now we skip the daemon spawn and go straight for the attach but with the
addition of -RR which lets screen spawn the daemon for us if it does
not yet exist.
Consequences:
creating multiple daemons with the same name.
not include the PID which we no longer have.
timeout.
screen. When we do this it is possible the session is already dead.
daemon will be respawned all while the Go program remains blissfully
unaware assuming it has been up this whole time. Does not change
anything in practice, just a bit different in terms of underlying
architecture.
In some ways this new architecture is actually simpler with roughly the
same functionality but it does not support concurrent attaches and theoretically
has a greater danger of desyncing from screen's own state (although at the
moment nothing concretely dangerous comes to mind).