Skip to content

fix(webui): the native acceptance host goes when it is done - #17

Merged
UncleMoc merged 1 commit into
mcode-webui:mainfrom
antianqi:fix/windows-native-pty-shutdown
Nov 10, 2026
Merged

UncleMoc merged 1 commit into
mcode-webui:mainfrom
antianqi:fix/windows-native-pty-shutdown

Conversation

@antianqi

Copy link
Copy Markdown
Collaborator

Change

The native PTY case failed at random on Windows with an afterAll hook timeout. The cause was the acceptance host staying alive after it had finished.

Node-pty's Windows console-list helper is forked on every terminal kill to enumerate the processes attached to the shell's console. A shell hosted by ConPTY has a pseudo-console rather than a console, so the helper's AttachConsole always fails there; the helper dies without answering, and node-pty falls back to a five-second timer to resolve the promise. That timer lives in the process that killed the terminal, so every kill left the host five seconds of work it had not asked for.

Measured on a Windows host, killing five terminals: the real work finished in 720ms, and the process still lived for 5.74s — one Error: AttachConsole failed per terminal, which is the line that shows up in the CI logs.

The acceptance host now exits once it has reported, in the send callback, which runs after the message has been flushed, so the report is not lost. The case went from 13-15 seconds to about 8.5.

The case now says so as well: the host has to be gone within two seconds of reporting that it closed, and a shutdown that does not arrive carries the host's own trace of where it was. Before this, a timeout said only that the hook ran out of time; it now says which step stopped answering.

The alternative — node-pty's useConptyDll option, which skips the helper entirely — was measured and is worse: the process did not exit at all.

Validation

  • The case, on its own: 5/5 pass, about 8.5s each (it was 13-15s).
  • Red before the fix: the host took 5.07s to exit after reporting, and the case failed with the native host did not exit. Green after it.
  • The full browser suite: 479 passed / 4 failed of 483. The 4 are screenshot comparisons against the *-win32.png baselines, which fail the same way without this change on this host.
  • check:source, typecheck, check:webui-motion, check:webui-overlays and test:release-tools pass.

Publication and contribution checks

  • I have permission to contribute these changes under the existing licenses applicable to the changed files/packages; imported material and its provenance are identified and existing notices are preserved.
  • No credentials, account data, real user content, internal source history or private review material is included.
  • Added/removed source files were reviewed before regenerating release/public-source.json; new tests are declared in test/vitest-suites.json where applicable.
  • Shared English/Chinese documentation and capability/verification records are updated where applicable. Mock/offline results are not described as live-service acceptance.

Maintainer handoff

Publication scope or license changes (if any): none.

Shared-source port: not needed / pending / complete. Record public PR references only; keep private links and review material out of this PR.


This follows #14, which is merged. The same five-second drag is in the product too: the desktop app lingers that long after closing the WebUI service with a terminal open, because node-pty's internal timer cannot be unref'd from outside. That is not addressed here.

The native PTY case failed at random on Windows with an "afterAll" hook
timeout. The cause was the host staying alive after it had finished.

Node-pty's Windows console-list helper is forked on every terminal kill to
enumerate the processes attached to the shell's console. A shell hosted by
ConPTY has a pseudo-console rather than a console, so the helper's
AttachConsole always fails there; the helper dies without answering, and
node-pty falls back to a five-second timer to resolve the promise. That
timer lives in the process that killed the terminal, so every kill left the
process five seconds of work it had not asked for. Measured on this host:
killing five terminals finished in 720ms, and the process still lived for
5.74s.

The acceptance host has nothing left to do once it has reported, so it now
exits there — in the send callback, which runs after the message has been
flushed, so the report is not lost. The case went from 13-15 seconds to
about 8.5.

The case now says so: the host has to be gone within two seconds of
reporting that it closed, and a shutdown that does not arrive carries the
host's own trace of where it was. Before this, a timeout said only that
the hook ran out of time; it now says which step stopped answering.

The alternative — node-pty's useConptyDll option, which skips the helper
entirely — was measured and is worse: the process did not exit at all.
@antianqi

Copy link
Copy Markdown
Collaborator Author

Ready to merge from my side — three-platform CI is green and this touches only packages/webui/, so it stays inside the webui package.

I could not merge it myself: the account this branch belongs to (antianqi) still reports viewerPermission: READ on this repository, so the maintain grant has not reached it yet. Merging it needs someone with merge rights, or the grant on that account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants