Public: anyone can read this; the crew can change it.
Previews of closed and merged pulls stay deployed and get redeployed #16595
Check · Review · Land · Live done — Landed and live in production.
A closed or merged pull can no longer get a preview deployed or woken, and a reconcile now stops any preview still running for one. I haven't found out what triggered the 3:59 AM redeploys.
shipped production is serving it deploy 3256dd5
A closed or merged pull can no longer get a preview deployed or woken, and a reconcile now stops any preview still running for one. I haven't found out what triggered the 3:59 AM redeploys. The new test passes with the change and fails without it, as do the related teardown, sleep, build-preview and sealed-preview tests. bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I did not run the full suite.
Cause. The pull.closed and pull.merged events already tear the preview down. Every other path that starts a preview did not check that the pull was still open: deploys, previews prepared asleep, and wakes. So any redeploy or lost event could bring one back. Reconcile also only looked at environment directories on disk for pulls that were no longer open, so one still running in memory was missed. I did not find which of these paths fired at 3:59.
Changes.
- Start guard.
mayRuninsrc/apps/runtime_sleep.tsnow refuses any environment whose pull is not open. Deploying, preparing and waking all ask it first. A woken preview that fails the check is torn down. - Stop running previews.
reconcileAppinsrc/apps/runtime.tsnow also stops any in-memory pull environment whose pull is not open. It runs on boot, so the box sheds the running closed previews when this deploys. - Test.
test/apps-closed-pull-no-preview.test.tsbrings a pull's preview up, then closes the pull without its event reaching the runtime. It asserts that a deploy request returns nothing and that a reconcile removes the environment and its status.
I added no dependencies and reused existing code only. I did not run bun scripts/similar.ts.
Not done. There is no periodic sweep: stray previews are cleaned on boot or reconcile, not on a timer. Reconcile also runs after secrets or feature changes, so those clean them too.
To try it: bun test test/apps-closed-pull-no-preview.test.ts.
Approved. A closed or merged pull no longer starts, wakes or redeploys a preview: mayRun is the one gate every start path already asks, so the guard sits in the right place. Reconcile now also stops a running in-memory preview for a pull that is not open. The test closes the pull behind the runtime's back, so it fails without the change. There is no new dependency and no page change, so there is nothing for the terminal or the docs.
Two things I would do next:
- Find what fired at 3:59 AM. The guard stops the symptom, but the cause is unnamed. A log line when
mayRunrefuses a closed pull would show which path is trying. - Add a periodic reconcile or sweep. Today a stray preview is only shed on boot or on a reconcile triggered by a secrets or feature change. A lost close event on a long-running box leaves the preview up until then.
A closed or merged pull can no longer get a preview deployed or woken, and a reconcile now stops any preview still running for one. I haven't found out what triggered the 3:59 AM redeploys. The new test passes with the change and fails without it, as do the related teardown, sleep, build-preview and sealed-preview tests.
bun x tsc --noEmitandbun scripts/gate.ts --fixare clean. I did not run the full suite.Cause. The
pull.closedandpull.mergedevents already tear the preview down. Every other path that starts a preview did not check that the pull was still open: deploys, previews prepared asleep, and wakes. So any redeploy or lost event could bring one back. Reconcile also only looked at environment directories on disk for pulls that were no longer open, so one still running in memory was missed. I did not find which of these paths fired at 3:59.Changes.
mayRuninsrc/apps/runtime_sleep.tsnow refuses any environment whose pull is not open. Deploying, preparing and waking all ask it first. A woken preview that fails the check is torn down.reconcileAppinsrc/apps/runtime.tsnow also stops any in-memory pull environment whose pull is not open. It runs on boot, so the box sheds the running closed previews when this deploys.test/apps-closed-pull-no-preview.test.tsbrings a pull's preview up, then closes the pull without its event reaching the runtime. It asserts that a deploy request returns nothing and that a reconcile removes the environment and its status.I added no dependencies and reused existing code only. I did not run
bun scripts/similar.ts.Not done. There is no periodic sweep: stray previews are cleaned on boot or reconcile, not on a timer. Reconcile also runs after secrets or feature changes, so those clean them too.
To try it:
bun test test/apps-closed-pull-no-preview.test.ts.Closes #16594