Repository navigation
perf: specialize zero-argument errors - #1362
Merged
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 28, 2026 12:39
9 of 10 tasks
5 of 6 tasks
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
…gument errors (#1856) The publish-time error specialization inlined a private __octaneNoArgError helper, carrying the full "Minified Octane error" text, into each of the 29 modules it rewrote. A consumer bundle carried one copy per such module, and a code-split application one in every chunk that included any of them. Rewritten modules now import formatNoArgumentErrorMessage from the new import-free src/error-message-no-arguments.ts. Messages, the call-time NODE_ENV read and #1362's binding-only contract (no generic formatter, no argument encoder) are unchanged. error-message.ts is untouched, so source-built bundles are byte-identical. Published dist, hydrating signals app: 9 copies -> 2 (-1,357 raw); split into 19 chunks: 22 copies in 10 chunks -> 2 in one (-3,662 raw, -1,105 gzip). Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
A binding-only consumer can retain the formatter for parameterized errors even though its own errors have no arguments. Specializing those calls removes that unnecessary dependency from the consumer's production bundle.
Changes
Validation
pnpm sync— not completed.pnpm format:checkpnpm typecheckpnpm testIn a public production binding fixture, the built bundle decreased by 86 gzip bytes. A mixed binding/runtime fixture increased by 75 gzip bytes and a full-runtime fixture by 172 gzip bytes; the optimization is scoped to dependency elision, not a universal size reduction.
Risk / follow-ups
process.env.NODE_ENVbehavior is unchanged. In environments that neither provideprocessnor replace the expression, an error path can still raise aReferenceError; standalone-browser support is separate work.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Published runtime JS and error strings are rewritten at build time; behavior is guarded by conservative AST checks and tests, but any transform bug would affect production error messages and consumer bundle graphs.
Overview
Adds a publish-time esbuild transform that rewrites Octane runtime modules whose only formatter usage is catalog-backed, literal zero-argument
formatClientError/formatServerErrorcalls. Those modules stop importing the generated formatter: development still returns full catalog strings viaprocess.env.NODE_ENV, and production uses a tiny inlined__octaneNoArgErrorhelper for minified messages. Mixed, parameterized, aliased, or otherwise unsafe patterns are left unchanged.The plugin runs on both ESM and CommonJS
distbuilds (build.mjs,buildPackageCommonjspluginsforwarding), and the Octane build now runspublished-errors.test.mjsto lock message contracts and assert binding-only production bundles no longer retainerror-codes.*.generated/error-message(orencodeURIComponent). Unit coverage lives inspecialize-error-calls.test.mjs. Patch changeset foroctane.Reviewed by Cursor Bugbot for commit 284f8d6. Bugbot is set up for automated code reviews on this repo. Configure here.