You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(onerror): inline error page template as string constant (#5868)
## Summary
Inlines the 1336-line error page HTML template into
`plugins/onerror/src/lib/onerror_page.ts` as a string constant. Removes
the runtime `readFileSync` + `import.meta.dirname` lookup for the
default template, sets the `templatePath` config default to an empty
string, and updates `app.ts` to lazy-load the built-in template only
when no custom template path is configured.
The fallback app-info serialization path now redacts sensitive config
values when `app.dumpConfigToObject()` is unavailable. This is an
observable security improvement for rendered error output; user-supplied
`templatePath` behavior remains unchanged.
## Why
This is **batch 1, part of a 19-PR split of #5863** (the egg-bundler
PR). #5863 is kept open as a tracking reference. This PR is independent
of the other batch-1 PRs.
Turbopack (and any static bundler) cannot follow `import.meta.dirname +
readFileSync` to a template file, so the file would be missing in a
bundled deployment. Inlining the HTML as a string constant makes the
plugin statically bundleable.
## Test plan
- [x] `pnpm exec vitest run plugins/onerror/test/onerror.test.ts` -
39/39 passed
- [x] `pnpm --filter=@eggjs/onerror typecheck`
- [x] `pnpm run build`
- [x] `pnpm exec oxlint --type-aware --type-check
plugins/onerror/src/app.ts plugins/onerror/src/lib/error_view.ts
plugins/onerror/src/lib/onerror_page.ts
plugins/onerror/test/onerror.test.ts plugins/onerror/tsdown.config.ts` -
0 errors, 1 existing warning on `app.close()`
## Stack context
Other batch-1 PRs (independent, can land in any order):
- `feat(utils): add setBundleModuleLoader runtime hook`
- `refactor(development): inline loader trace template as string
constant`
- `refactor(watcher): use direct class imports for event sources`
Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Built-in error page template now exposed for consumers; includes
stack-frame visualization, filtering, frame selection, inline code
preview, and syntax highlighting.
* **Bug Fixes & Improvements**
* Built-in template used by default when no custom template path is set.
* Safer frame selection and more robust client-side error-page behavior.
* Config serialization now redacts sensitive values and handles circular
references.
* **Tests**
* Added tests verifying config redaction in serialized error output.
* **Chores**
* Added a public package subpath export to allow importing the
error-page asset.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments