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

A production that is not serving is skipped by the look sweep with its reason, never pictured through a public name #16687

Merged opened this

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

Merged

The sweep now skips an app that isn't serving: no browser starts, and each look row records not serving as its reason. tsc is clean and test/looks.test.ts, test/look-browser-start.test.ts and test/look-backoff.test.ts pass, except for the real-Chromium capture test.

Notes

shipped production is serving it deploy 354c752

opened this

The sweep now skips an app that isn't serving: no browser starts, and each look row records not serving as its reason. tsc is clean and test/looks.test.ts, test/look-browser-start.test.ts and test/look-backoff.test.ts pass, except for the real-Chromium capture test. That test needs the sandbox's Chromium and fails the same way on a clean checkout, so the forge's check will have to cover it.

  • The skip (src/looks/service.ts): before it opens a browser, the look probes the app's own port. A 404 or any 5xx now counts as not serving, where before only 5xx counted and a 404 was pictured.
  • Silence stays as it was: an app that never answers still records the old NOT_ANSWERING reason. A skipped look goes through the existing doubling retry (failed(item)).
  • Reused: the existing answered() poll and appAnswers probe. The test seam answers now may also return NOT_SERVING.
  • The target (src/looks/capture.ts): the browser's host-resolver rule now maps the app's name to loopback and makes every other name fail to resolve (MAP * ~NOTFOUND, EXCLUDE 127.0.0.1). A bounce to an https public name now fails there instead of reaching a different server and producing ERR_CERT_AUTHORITY_INVALID. The capture flow itself is unchanged.
  • Tests: a new test in test/looks.test.ts checks that a 404 app gets no capture and not serving on every row, and that a serving app is still pictured. The flag assertion in test/look-browser-start.test.ts now expects the new rule string.

Left out:

  • Other statuses: 401, 403 and redirects still count as serving, since a private app answers them.
  • Hop test: no test drives a real https bounce through Chromium, because the sandbox can't run one.
  • Wait before skipping: a 404 app is probed for the same 5 s window as a warming-up one before it is skipped, so a slow start isn't skipped by mistake.

To try it: point a production at a page that returns 404 and run a sweep. Its looks show not serving and no browser starts.

🤖 Generated with Claude Code

Closes #16256

1 earlier comment · 1 event
commented

The sweep now skips an app that isn't serving: no browser starts, and each look row records not serving as its reason. tsc is clean and test/looks.test.ts, test/look-browser-start.test.ts and test/look-backoff.test.ts pass, except for the real-Chromium capture test. That test needs the sandbox's Chromium and fails the same way on a clean checkout, so the forge's check will have to cover it.

  • The skip (src/looks/service.ts): before it opens a browser, the look probes the app's own port. A 404 or any 5xx now counts as not serving, where before only 5xx counted and a 404 was pictured.
  • Silence stays as it was: an app that never answers still records the old NOT_ANSWERING reason. A skipped look goes through the existing doubling retry (failed(item)).
  • Reused: the existing answered() poll and appAnswers probe. The test seam answers now may also return NOT_SERVING.
  • The target (src/looks/capture.ts): the browser's host-resolver rule now maps the app's name to loopback and makes every other name fail to resolve (MAP * ~NOTFOUND, EXCLUDE 127.0.0.1). A bounce to an https public name now fails there instead of reaching a different server and producing ERR_CERT_AUTHORITY_INVALID. The capture flow itself is unchanged.
  • Tests: a new test in test/looks.test.ts checks that a 404 app gets no capture and not serving on every row, and that a serving app is still pictured. The flag assertion in test/look-browser-start.test.ts now expects the new rule string.

Left out:

  • Other statuses: 401, 403 and redirects still count as serving, since a private app answers them.
  • Hop test: no test drives a real https bounce through Chromium, because the sandbox can't run one.
  • Wait before skipping: a 404 app is probed for the same 5 s window as a warming-up one before it is skipped, so a slow start isn't skipped by mistake.

To try it: point a production at a page that returns 404 and run a sweep. Its looks show not serving and no browser starts.

🤖 Generated with Claude Code

Changes requested — before the latest push

The skip and the resolver rule are the right shape, but box 3 is not met: no test fails if the 404 mapping is removed.

Fix first: the new test injects async () => NOT_SERVING through the answers seam, so it never runs appAnswers, which holds the only change that makes a 404 count as not serving (res.status === 404 || res.status >= 500). Delete that line's 404 clause and the test stays green. Add a test that starts a real Bun.serve answering 404 on a loopback port and checks that startLooks with no answers override (or appAnswers exported and called directly) records not serving and starts no browser. Add a 200 case to the same server so a serving app is still pictured through the real probe.

Smaller:

  • In test/look-browser-start.test.ts the expect(flags).toContain(...) line is now over the wrap width. Run bun scripts/gate.ts --fix and commit what it rewraps.
  • The NOT_SERVING doc comment in src/looks/service.ts is a single long line. Rewrap it.
  • Box 2 rests on a Chromium rule string that nothing exercises. At minimum, add one assertion that lookFlags ends the rules with EXCLUDE 127.0.0.1, so the DevTools port cannot be cut off by a later edit. Say in the pull that the real https bounce was not run.

Not a change request: 401, 403 and redirects staying serving is right for a private app.

commented

I've pushed changes for each point in the review. tsc is clean and the targeted tests pass, apart from the real-Chromium capture test, which fails the same way on a clean checkout in this sandbox. The forge's check will have to cover it.

  • Real probe test: the new test/look-probe.test.ts runs appAnswers, now exported, against real loopback Bun.serve servers.
    • A 404 and a 503 return NOT_SERVING.
    • A 200 and a 302 return true.
    • A closed port returns false, so silence still records the old NOT_ANSWERING.
    • Deleting the 404 clause in appAnswers now fails that test.
  • Resolver rule: the same file asserts that lookFlags ends its host-resolver rules with EXCLUDE 127.0.0.1 and contains MAP * ~NOTFOUND, so a later edit can't cut off the DevTools port.
  • Wrapping: I rewrapped the NOT_SERVING comment and the long toContain line by hand, because gate.ts --fix changed nothing in either file. The gate also reports a 0.73 similarity between answeringTrial and trial in test/looks.test.ts, which I left alone.
  • Not done: I did not drive the answers-free path through startLooks itself. That test still injects answers and covers the wiring: a not-serving verdict records not serving and starts no browser. The real probe is tested separately in test/look-probe.test.ts. Running startLooks end to end against a real server would need a runtime whose envStatus port points at that server, which the existing fixture doesn't offer.
  • Not run: the real https bounce through Chromium was not run here. The resolver rule is covered only by the string assertions above.
Approved

Both earlier asks are met. The real probe is now tested against loopback servers: 404 and 503 give not serving, 200 and 302 give serving, and a closed port gives silence. The resolver rule keeps EXCLUDE 127.0.0.1, so DevTools stays reachable, and a test pins that. I found nothing new in the lines that changed since 08f114ef303a. I did not run a real https bounce through Chromium, so the resolver rule is covered by its flag assertions only. Two things I would do next, both non-blocking: (1) Non-blocking: drive startLooks without the answers seam against a real 404 server, once the fixture can point envStatus at one. (2) Non-blocking: the answeringTrial and trial helpers in test/looks.test.ts are 0.73 similar, so fold them into one.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs