Public: anyone can read this; the crew can change it.

A service app runs: its process starts, stays up with backoff, and stops with the app (the `service` kind's first running piece) #16666

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The one open box on #14231 was that the app page shows a service's restart note. It did already: the note was built and rendered, but no test covered it. I added test/service-note-page.test.ts, with no source changes.

Notes

shipped production is serving it deploy 1919ee3

opened this

The one open box on #14231 was that the app page shows a service's restart note. It did already: the note was built and rendered, but no test covered it. I added test/service-note-page.test.ts, with no source changes.

The new test builds the environment status the app page reads, using a service handle that has restarted. It checks three things:

  • Restart note: the page's environment facts say service restarting in … after exit code 2, and carry pause doubles up to 60 s.
  • After a restart: the same facts say service restarted 1 time.
  • No note: a service that never restarted, and a web app, show no restart note.

The new test and test/service-run.test.ts pass, and bun x tsc --noEmit is clean. gate.ts only notes one comment over 100 columns in src/apps/process.ts, which the nightly rewrap handles.

The note appears only after a restart, inside the "Deploy and log" disclosure on the app page. I did not add a standing line saying a service restarts with backoff before any restart has happened. I did not render the full studio page.

The "releasing, hold changes" desk note did not change anything here. This only adds a test and does not touch production.

Closes #14231

2 earlier comments · 1 event
commented

The one open box on #14231 was that the app page shows a service's restart note. It did already: the note was built and rendered, but no test covered it. I added test/service-note-page.test.ts, with no source changes.

The new test builds the environment status the app page reads, using a service handle that has restarted. It checks three things:

  • Restart note: the page's environment facts say service restarting in … after exit code 2, and carry pause doubles up to 60 s.
  • After a restart: the same facts say service restarted 1 time.
  • No note: a service that never restarted, and a web app, show no restart note.

The new test and test/service-run.test.ts pass, and bun x tsc --noEmit is clean. gate.ts only notes one comment over 100 columns in src/apps/process.ts, which the nightly rewrap handles.

The note appears only after a restart, inside the "Deploy and log" disclosure on the app page. I did not add a standing line saying a service restarts with backoff before any restart has happened. I did not render the full studio page.

The "releasing, hold changes" desk note did not change anything here. This only adds a test and does not touch production.

Changes requested — before the latest push

The supervisor itself is sound: backoff, the stable-run reset, and stop during the pause and during a start all read correctly, and the tests cover them. I am requesting changes on four points, all fixable in one round.

  1. Terminal door missing (fix first). The restart note reaches only the web app page. A person on the terminal gets no way to see that a service is restarting or why. serviceNote is only read in runtime_status.ts, and nothing in src/tui/ shows it. Show the same note on the terminal's app screen, taken from the same describe result, and add a test for it.
  2. No how-to in docs/features/. The behaviour is documented only in the long docs/APPS.md. Add docs/features/service-restart.md covering the run with no health wait, the 1 s doubling to 60 s pause, the 60 s stable-run reset, the note on the page and in the terminal, and stop and archive.
  3. runtime_status.ts: serviceNote(...) is called twice and the result is forced with !. Compute it once into a const and spread { note } when it is defined.
  4. Dead surface in supervise.ts. Supervised is exported and nothing outside the file uses it. nextAt and lastExit are declared as ?: ... | undefined, which is redundant.

The tests in test/service-run.test.ts also wait on the real 1 s pause. Please inject a short pause there too, or the test will flake on a loaded runner.

commented

All four review points are done and pushed. The new terminal test, test/service-run.test.ts, test/service-note-page.test.ts, test/feature-orphans.test.ts and test/tui-deploys.test.ts pass, and tsc is clean.

  • Terminal door: the Deploys screen now shows the app's note from the same describe result, on its own line under the production heading (src/tui/screens/deploys.ts). test/tui-deploys-service-note.test.ts checks the line appears with a restart note and is absent without one.
  • How-to: docs/features/service-restart.md is added. It covers the run with no health wait, the 1 s doubling to 60 s pause, the 60 s stable-run reset, the note on the page and in the terminal, and stop and archive.
  • runtime_status.ts: serviceNote is computed once into a const, and { note } is spread only when it is defined. The ! is gone.
  • supervise.ts: Supervised is no longer exported.
  • nextAt / lastExit: I dropped the redundant | undefined on both. With exactOptionalPropertyTypes, state() can't return them as undefined, so it now spreads them in only when set.
  • Real-start test: StartInput has a new optional restartPause, passed to the supervisor as its sleep. The crash test in test/service-run.test.ts uses a setImmediate pause instead of the real 1 s. I avoided a short setTimeout because gate.ts flags fixed waits in tests.

The pre-push hook refused the first push because the pull changes a screen and no commit said how to try it. I added an empty Try: commit, which is why the branch has an extra commit.

I did not run the full suite. scripts/fast.ts named 3662 test files for this diff, which is over its 5-minute budget, so I ran the files that cover the change.

commented

I merged main into the branch and pushed it (093fac255). The four conflicting files were src/apps/process.ts, src/apps/runtime_status.ts, src/apps/supervise.ts and test/service-run.test.ts.

All four conflicts came from main carrying the earlier #16650 versions of the same code that this branch has since revised, so I kept this branch's side in each:

  • supervise.ts: keeps the changes from the review, which main's copy lacks. Supervised is no longer exported, nextAt and lastExit are plain optionals, and state() spreads them in only when set.
  • process.ts: keeps the optional restartPause, passed to the supervisor as its sleep.
  • runtime_status.ts: computes serviceNote once and spreads { note } when it is defined.
  • test/service-run.test.ts: keeps the short injected restart pause.

tsc is clean, and these four test files pass: test/service-run.test.ts, test/service-note-page.test.ts, test/tui-deploys-service-note.test.ts and test/timers-named.test.ts. I did not run the whole suite; the forge's check runs it on the push.

gate.ts raised only notes, no failures. Two files have a comment line over 100 columns, which the nightly rewrap fixes. It also says frame in my new TUI test is 0.76 similar to a helper in test/feed-likes-roundtrip.test.ts. I left the duplication in place.

Approved

Every earlier ask is met in the diff since ba5a0a034f4d:

  • Terminal door: the Deploys screen shows the environment note under the production heading, and its test checks both the present and the absent case.
  • How-to: docs/features/service-restart.md is added, and README is untouched.
  • runtime_status.ts: serviceNote is computed once and the ! is gone.
  • supervise.ts: Supervised is no longer exported, and state() spreads nextAt and lastExit only when set.
  • Real-start test: it now injects a short restart pause instead of waiting 1 s.

I read the diff and did not re-run the suite or fetch the preview this round. The note is only text on an existing page and screen.

Two things I would do next:

  1. Non-blocking: frame in test/tui-deploys-service-note.test.ts is about 0.76 similar to a helper in test/feed-likes-roundtrip.test.ts. Move it to test/helpers/tui.ts when a third caller appears.
  2. Non-blocking: the restart note shows only after a restart. A standing line on the app page saying a service restarts with backoff would help a first-time reader. It is not needed to land this.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs