Skip to content

fix(generate): lazy-load dart renderer so it can't 500 all languages - #8

Merged
dev-jodee merged 1 commit into
mainfrom
fix/dart-lazy-load
Jul 17, 2026
Merged

fix(generate): lazy-load dart renderer so it can't 500 all languages#8
dev-jodee merged 1 commit into
mainfrom
fix/dart-lazy-load

Conversation

@dev-jodee

Copy link
Copy Markdown
Owner

Fixes a production outage: /api/generate 500'd for ALL languages after the Dart deploy. codama-renderers-dart was required at module top level; its mispublished exports (import -> missing .mjs) defeat Vercel's file tracer, so the package was omitted from the serverless bundle and the top-level require threw at import time, taking down every language. Fix: lazy-load the require inside the dart case (failure now caught, only affects dart) + outputFileTracingIncludes to force the package into the /api/generate lambda. Verified locally: prettier/lint/tests(25)/build green; isolation test (package removed) -> typescript 200, dart caught error, no crash; package present -> dart 200 with 12 .dart files.

The dart renderer was required at module top level, so when Vercel's file
tracer omitted the mispublished codama-renderers-dart package from the
serverless bundle, the require threw at import time and 500'd /api/generate
for ALL languages, not just dart.

Move the require into the dart switch case so a resolution failure is caught
by the route handler and only affects dart. Add outputFileTracingIncludes to
force the package's files into the generate route's bundle so dart works too.
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
castaway Ready Ready Preview, Comment Jul 17, 2026 4:04pm

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dart-lazy-load

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dev-jodee
dev-jodee merged commit 4f9392e into main Jul 17, 2026
4 checks passed
@dev-jodee
dev-jodee deleted the fix/dart-lazy-load branch July 17, 2026 16:29
dev-jodee added a commit that referenced this pull request Jul 17, 2026
#8 stopped the total outage but dart itself still 500'd: its CJS build
(loaded via createRequire) requires the .cjs variants of a large
@codama/@solana/@noble tree that Next only bundles as .mjs, so
@codama/visitors-core/dist/index.node.cjs was missing from the lambda.

Load dart's real ESM build by path instead (bundler-ignored so Turbopack
leaves it a runtime import, avoiding its "expression too dynamic" error),
which reuses the already-bundled .mjs deps. Broaden outputFileTracingIncludes
to guarantee dart's ESM closure (@codama/@solana/@noble) is present.
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.

1 participant