Skip to content

fix: render error pages and mail without @arkstack/view installed - #29

Merged
3m1n3nc3 merged 1 commit into
mainfrom
fix/optional-views
Nov 7, 2026
Merged

3m1n3nc3 merged 1 commit into
mainfrom
fix/optional-views

Conversation

@3m1n3nc3

@3m1n3nc3 3m1n3nc3 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Apps that don't install @arkstack/view crashed with globalThis.view is not a function whenever an HTML error page was rendered, because renderError() in @arkstack/common called the view() global unconditionally. MailNotification had the same problem when no .html() template was set.

  • @arkstack/common: new ErrorPage class. It renders ~arkstack/common.error through view() when the global is registered, and falls back to a built-in (escaped) HTML document otherwise. renderError() keeps its signature and delegates to it, so the express/h3/fastify error handlers need no changes.
  • @arkstack/notifications: MailNotification.renderHtml() uses the html template, then the view, then a built-in layout matching mail.edge. A custom .view(...) without @arkstack/view installed throws a clear error instead of the TypeError.

This mirrors how @arkstack/inertia already falls back to builtInTemplate() when the view layer is missing.

Tests

  • packages/common/tests/error-page.test.ts: fallback page, stack omission, and rendering through the view global.
  • packages/notifications/tests/notification.test.ts: built-in mail layout without the view global, and the error for a custom view.

Six existing notification mail tests fail locally both before and after this change (Package views directory not found, because the sandbox has no built node_modules/@arkstack/notifications/resources/views); they're unrelated to this diff.

@3m1n3nc3 3m1n3nc3 self-assigned this Nov 7, 2026
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@3m1n3nc3
3m1n3nc3 merged commit 05fe407 into main Nov 7, 2026
4 checks passed
@3m1n3nc3
3m1n3nc3 deleted the fix/optional-views branch November 7, 2026 13:52
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