sorenisanerd/gotty

Zmodem transfers/cancellations hang terminal

dmartin opened this issue · 7 comments

What version of GoTTY are you using (gotty --version)?

1.4.0

What operating system and browser are you using?

Ubuntu 22.04, Chrome

What did you do?

If possible, please provide the command you ran.

./gotty -p 7681 -w bash

What did you expect to see?

Action Expected Behavior
rz, cancel upload (close modal) rz exits and terminal prompt advances
sz <filename>, click Accept File is transferred to browser, terminal prompt advances
sz <filename>, click Decline sz exits and terminal prompt advances
sz <filename>, close modal sz exits and terminal prompt advances

What did you see instead?

If possible, please provide the output of the command and your browser's console output.

Action Observed Behavior
rz, cancel upload (close modal) Prompt is stuck on rz waiting to receive.**B0100000023be50
sz <filename>, click Accept File is transferred to browser, terminal prompt is stuck on **B00000000000000, JavaScript console reports errors: Uncaught PROTOCOL: Only thing after ZFIN should be “OO” (79,79), not: ... at zsession.js:563
sz <filename>, click Decline Modal displays "Skipping..." until manually closed, JavaScript console reports errors: Uncaught PROTOCOL: Only thing after ZFIN should be “OO” (79,79), not: ..., sz: skipped: <filename> is written to terminal but prompt is stuck
sz <filename>, close modal Prompt is stuck on **B00000000000000 until it eventually times out

Ugh. That does not look great. :( I wonder if all of these are caused by the same core issue. It sounds like I'm not resetting the Zmodem state correctly at the right times.

Thank you very much for this bug report. I really appreciate your attention to detail. It was very, very helpful.

Here's a test build:
https://github.com/sorenisanerd/gotty/actions/runs/2976008354

Can you take it for a spin? Thanks!

Hi @sorenisanerd, it seems like there are some improvements with that build, still seeing some issues with sz handling though.

  • Cancelling rz uploads does work now!
  • Still seeing the same results (JavaScript protocol error and hung prompt) when accepting or declining an sz-initiated download.
  • Closing the sz modal now seems to work the same as choosing "Decline" but encounters the same issues.

Ugh. It works for me. I guess I'm looking for a race condition. Thanks for checking! I'll get back to you when I've dug deeper :)

Thanks for looking into it, but please don't stress too much on my account! This is not blocking any work for me, just something I ran into while testing out terminal-sharing tools.

Same problem

I've spent a lot of time trying to reliably reproduce this. It happens sometimes, but I've been unable to trigger it while running either gotty, bash, or sz under strace. I've tried many other ways to observe what is happening, but whenever I get close, it stops happening. What I have been able to observe is that occasionally, the terminating OO from sz gets swallowed SOMEWHERE, but it's a bit of a mystery where or why. The gotty process on the server simply does not see it, so it can't pass it along to the frontend.

Are you doing anything interesting with your command prompt? $PS1 trickery? PROMPT_COMMAND doing anything cool? I don't know. I'll keep digging, but even if this turns out to be a bug in lrzsz or something, we have to support existing versions of it, so I'll whip up a patch for zmodemjs to fix it.

Fwiw, we're not alone:
tsl0922/ttyd#239
tsl0922/ttyd#279
Eugeny/tabby#6259
cferdinandi/tabby#132
Eugeny/tabby#5196
trzsz/tabby-trzsz#2
Eugeny/tabby#5132