Dev server loses its exit code and output across a stimd restart: bring back a per-workspace helper as its parent

Open
#5,571 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
node.js, react-native, typescript
Domain
cli, devtools

Research direction

Start with the regression audit in packages/stim-cli/src/stimd/metro/children.ts, stimd/metro/child-server.ts, and stimd/main.ts, then read the 1.40.0 versions of those files. The proposed design starts as an llp/ decision document; define how a per-workspace helper survives stimd restarts and preserves output and exit status. Done means the decision document is reviewed and implementation scope is clear.

Written by the indexing model from the issue text.

Description

area: cli area: metro priority: P1 type: bug

Problem

Since the per-workspace dev-server supervisor moved into stimd, Metro (Expo child, metro.command, bare React Native metro-host.cjs, Re.Pack) is a stimd child. When stimd restarts (crash, in-place update, engine switch, idle exit), the new stimd adopts the running dev server without a process handle:

  • its exit code is lost: the adopted child settles with settleExited(child, null, null) and logs "exit code unknown";
  • output written between the dead stimd's last read and adoption is never recorded, because offsets are saved only on a graceful close and the adopter starts at end of file;
  • output written by group members after the leader exits is not captured, because the tail stops at the leader's exit;
  • on Windows a running dev server holds a stimd update and stops with stimd.

1.40's supervisor held the dev server's pipes and recorded its exit code.

Maintainer decisions, 2026-11-12: "i think supervisors might still be needed to allow stimd restarting? I think we need to keep this in mind for future designs" and "Bring back helper for both and fix 3 to 6 in stimd". This issue covers the dev server; the physical iPhone console helper is a separate lane.

Evidence

Regression audit of v1.40.0 against origin/main 7aa28e5a8, sections A1, A3, A4, A6: packages/stim-cli/src/stimd/metro/children.ts (adoption with handle: null, settle with null code, leader-exit early return), stimd/metro/child-server.ts (tail start offset, tail stops at leader exit), stimd/main.ts (heldBy: 'dev-servers' on Windows).

Cause

The process that holds the dev server's pipes and is its parent is stimd. The exit status of a process can only be read by its parent, and a pipe or tail that the parent owns ends with it.

Fix idea

A small per-workspace helper process, detached from stimd, is the dev server's parent. It holds the pipes, writes every line and the exit (code or signal) to the workspace's Metro log sink, and survives stimd restarts. stimd stays the coordinator (start, stop, readiness, Metro claim, heartbeat, adoption) and finds the helper again through its claim and verified process identity. Design first as an llp/ decision document, then implementation.

Dominant language
TypeScript
Stars
100
Forks
8
Avg merge
4h 24m
Merged PRs (30d)
971

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from appandflow/stim

All issues in appandflow/stim

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.