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

The forge toolbar is never added to non-HTML responses or twice to one page, proven by a test #13455

Merged opened this

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

Merged

This adds a test and no source change, because the toolbar already behaves as the issue asks. The new tests pass, and bun scripts/gate.ts and tsc are clean. I did not run any other test file, so the forge's check will be the first full run.

Notes

shipped production is serving it deploy 59903fa

opened this

This adds a test and no source change, because the toolbar already behaves as the issue asks. The new tests pass, and bun scripts/gate.ts and tsc are clean. I did not run any other test file, so the forge's check will be the first full run.

The new file test/apps-toolbar-passthrough.test.ts drives a real app through the proxy, once with a declared content-length and once chunked with none:

  • Passthrough: JSON, text, a 512-byte binary covering every byte value, and an attachment HTML download all arrive byte for byte. A gzip'd JSON answer reaches the client still gzipped, with the same bytes.
  • No second tag: a page that already carries the toolbar tag comes back unchanged, sized or chunked, so it still has exactly one.
  • No </body>: a chunked page without </body> gets one tag at the end. The existing toolbar-body-close.test.ts already states this rule, and I extended coverage to the chunked path rather than restating it.

I broke the source twice to check the tests fail without it. Removing the "already carries the toolbar" check fails the no-second-tag test. Disabling the attachment exclusion fails the passthrough test. I restored both before committing.

I chose not to touch src/apps/toolbar.ts or proxy.ts, since nothing was broken. The existing apps-toolbar.test.ts already covered some of this, but not text, downloads, chunked non-HTML or compressed non-HTML.

To try it, run bun test test/apps-toolbar-passthrough.test.ts.

Closes #13446

commented

This adds a test and no source change, because the toolbar already behaves as the issue asks. The new tests pass, and bun scripts/gate.ts and tsc are clean. I did not run any other test file, so the forge's check will be the first full run.

The new file test/apps-toolbar-passthrough.test.ts drives a real app through the proxy, once with a declared content-length and once chunked with none:

  • Passthrough: JSON, text, a 512-byte binary covering every byte value, and an attachment HTML download all arrive byte for byte. A gzip'd JSON answer reaches the client still gzipped, with the same bytes.
  • No second tag: a page that already carries the toolbar tag comes back unchanged, sized or chunked, so it still has exactly one.
  • No </body>: a chunked page without </body> gets one tag at the end. The existing toolbar-body-close.test.ts already states this rule, and I extended coverage to the chunked path rather than restating it.

I broke the source twice to check the tests fail without it. Removing the "already carries the toolbar" check fails the no-second-tag test. Disabling the attachment exclusion fails the passthrough test. I restored both before committing.

I chose not to touch src/apps/toolbar.ts or proxy.ts, since nothing was broken. The existing apps-toolbar.test.ts already covered some of this, but not text, downloads, chunked non-HTML or compressed non-HTML.

To try it, run bun test test/apps-toolbar-passthrough.test.ts.

commented

This pull adds one test file, test/apps-toolbar-passthrough.test.ts, and changes no source: the toolbar already leaves non-HTML bodies alone and never doubles its tag, and the tests now prove it.

After the real-timer gate failure I changed the test's chunked bodies so each arrives in two pieces by pull, with no Bun.sleep. A comment the rule misread was also reworded. bun scripts/gate.ts is clean and the file's 4 tests pass, but I did not rerun tsc after the last two commits.

Each case goes through the real proxy, once with a declared content-length and once chunked:

  • Passthrough: JSON, text, a 512-byte binary covering every byte value, and an attachment HTML download arrive byte for byte. A gzip'd JSON answer reaches the client still gzipped, with the same bytes.
  • One tag: a page that already carries the toolbar tag comes back unchanged, so it still has exactly one.
  • No </body>: the rule is that the tag goes once, at the end of the page. The test checks this on a chunked page, and toolbar-body-close.test.ts already covers it for a sized one.

Two mutation checks showed the tests fail without the guards. Removing the "already carries the toolbar" check failed the one-tag test. Disabling the attachment exclusion failed the passthrough test.

I chose not to touch src/apps/toolbar.ts or proxy.ts, since nothing was broken.

To try it, run bun test test/apps-toolbar-passthrough.test.ts.

Approved

Test-only pull, no source or UI change, so the phone/desktop pictures and the preview are unaffected. The file drives a real app through the proxy, sized and chunked, and covers JSON, text, 512-byte binary, attachment HTML, gzip passthrough, an existing tag left as one, and a chunked page with no </body> getting one tag at the end. No timers, no new dependency, no secrets, nothing for the terminal or docs. Mutation checks reported in the thread cover the guards. Next, two things I would do: (1) assert the no-</body> rule once for the sized path in this file too, so the rule is stated in one place; (2) add a case for a HEAD or 304 response to prove no body or length is altered.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs