Skip to content

fix(cli): format page bundler failures - #1406

Merged
nicolas-abril merged 2 commits into
bendlang:mainfrom
oxura:fix/1399-page-bundle-errors
Oct 8, 2026
Merged

nicolas-abril merged 2 commits into
bendlang:mainfrom
oxura:fix/1399-page-bundle-errors

Conversation

@oxura

@oxura oxura commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #1399.

Move the HTML dispatch under the existing CLI error boundary and await it there. Preserve AggregateError child diagnostics instead of replacing the actual missing-page/output-path reason with AggregateError: Bundle failed. CLI option ordering and successful bundling are unchanged. Document nonzero page-build failure behavior in the guide; permanent token caps are unchanged.

Verification on Linux x86_64 / Bun 1.3.13:

  • Before: missing HTML and an existing-file output path exit 1 with Bun's unhandled-error banner.
  • After: both exit 1 with Error: Bundle failed plus their concrete BuildMessage; no unhandled-error banner. The existing output file remains byte-identical.
  • A valid static HTML page still builds and exits 0.
  • Invalid HTML options and a missing .bend entry retain their existing errors.
  • bun gates/repo.ts: PASS: 50 / 50.

No browser behavior change is claimed. The separately reported empty-chunk/import-validation issue #1400 is not addressed. No mini-cluster gates were run; this is a local actual-CLI before/after smoke, not a mocked Bun.build test.

…ts file, line and code frame; a page refuses --verdict and extra arguments; the guide is unchanged; ping checks a page whose import does not resolve

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@nicolas-abril

Copy link
Copy Markdown
Collaborator

Thanks, @oxura! Moving the page build under the CLI's error handling was the right fix. Before merging I pushed one commit on top (ab6b689):

  • Errors keep their location. The AggregateError branch formatted each bundler error with String(), which dropped its file, line, column and code frame. For a page whose import doesn't resolve, that left only Error: Bundle failed and ResolveMessage: Could not resolve: "./nothere.ts", with no hint of which module. For a failing .bend import it lost the at …/bad.bend:0 line, so you couldn't tell which .bend file failed. book_err now prints each one with Bun.inspect(m, { colors: false }), which keeps the frame and at file:line:col. Each line starts with the level (error:) rather than Bun's class name, and there's no separate Error: Bundle failed header.
  • No blank line on an empty list. An AggregateError with no child errors prints just itself.
  • A page rejects flags it would ignore. bend page.html -o dist --verdict and bend page.html extra -o dist used to build and exit 0. They now stop with "a page bundles with -o ", the way a .bend file rejects options that don't apply to it.
  • Smaller diff. The option checks stay where they were on main. Only the cli_bundle call moves inside the try, which is all it needs to go through the CLI's error output.
  • Guide reverted. We're keeping the guide as it was.
  • Regression check. tests/ only holds .bend programs compared against their #| output, so this lives in gates/ping.ts, which already runs the installed bend executable. It builds a page with an unresolvable import and expects exit 1, the Could not resolve message, page.ts:1:, and no Bun v crash banner. It fails on the earlier version of this PR and passes now.

Checked with the real CLI: a missing import, a failing .bend import, a missing page, -o pointing at an existing file (left untouched), --verdict and an extra argument all exit 1 with no crash banner, and a valid page still builds. gates/_run.ts gives repo 50/50, ping 47/47 and test 1587/1587.

@nicolas-abril
nicolas-abril merged commit bc4afe3 into bendlang:main Oct 8, 2026
1 check passed
@oxura

oxura commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up and merge. Preserving each bundler diagnostic’s code frame/location and rejecting arguments a page would ignore is the right behavior. gates/ping.ts is the appropriate home for the installed-CLI regression. I will preserve your ab6b6897 follow-up and the reverted guide, and use that diagnostic/test-placement convention for future CLI fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bend <page>.html -o <dir> prints Bun's raw unhandled-error banner (missing page, or -o pointing at an existing file)

2 participants