Skip to content

v1.32.0.1 fix: browse daemon stop/restart crash-loop - defer shutdown after response#2020

Open
devkd111 wants to merge 1 commit into
garrytan:mainfrom
devkd111:fix/browse-stop-restart-crash-loop
Open

v1.32.0.1 fix: browse daemon stop/restart crash-loop - defer shutdown after response#2020
devkd111 wants to merge 1 commit into
garrytan:mainfrom
devkd111:fix/browse-stop-restart-crash-loop

Conversation

@devkd111

Copy link
Copy Markdown

Problem

meta-commands.ts case 'stop' and 'restart' call await shutdown() BEFORE returning the HTTP response. shutdown() tears down the HTTP listener and calls process.exit(), so the response never flushes. The CLI sees ECONNRESET, its crash-retry logic re-sends the command, and the daemon logs "crashed twice in a row" before exit.

Fix

Replace await shutdown() with setTimeout(() => { shutdown(); }, 0) in both 'stop' and 'restart' cases. This defers the shutdown until after the current execution context completes, allowing the HTTP response to flush before the listener is torn down.

Test

Added regression tests in browse/test/commands.test.ts:

  • Server Control > stop returns response before shutdown fires — verifies shutdown calls are deferred (not synchronous)
  • Server Control > restart returns response before shutdown fires — same for restart
  • Server Control > status returns healthy — baseline

All 226 existing tests pass, zero regressions.

Files changed

  • browse/src/meta-commands.ts — defer shutdown via setTimeout(0)
  • browse/test/commands.test.ts — regression tests (3 new, 226 total pass)
  • VERSION — bump 1.32.0.0 to 1.32.0.1
  • package.json — bump 1.32.0.0 to 1.32.0.1
  • CHANGELOG.md — entry for 1.32.0.1

…ponse

meta-commands.ts called await shutdown() before returning the HTTP
response, tearing down the listener so the response never flushed.
The CLI saw ECONNRESET, crash-retry re-sent the command, and the
daemon logged 'crashed twice in a row' before exit.

Fix: defer shutdown() via setTimeout(0) so the response flushes first.
Added regression tests for both stop and restart commands.

Version bump: 1.32.0.0 → 1.32.0.1
@trunk-io

trunk-io Bot commented Jun 16, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions github-actions Bot changed the title fix: browse daemon stop/restart crash-loop - defer shutdown after response v1.32.0.1 fix: browse daemon stop/restart crash-loop - defer shutdown after response Jun 16, 2026
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.

1 participant