Skip to content

chore: Expose app layout error-boundary catches for canary detection#4699

Draft
gethinwebster wants to merge 5 commits into
mainfrom
dev-v3-gethinw-applayout-error-boundary-detection
Draft

chore: Expose app layout error-boundary catches for canary detection#4699
gethinwebster wants to merge 5 commits into
mainfrom
dev-v3-gethinw-applayout-error-boundary-detection

Conversation

@gethinwebster

@gethinwebster gethinwebster commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Lets our integration/canary tests detect errors that an App Layout error boundary caught.

What changed

  • Record + expose caught errors. AppLayoutBuiltInErrorBoundary records each caught error ({ appLayoutPart, message }) into a bounded module registry. A new getAppLayoutErrors() / clearAppLayoutErrors() accessor is exposed on the App Layout root element's __awsui__ (via attachAppLayoutErrorBoundaryTestHooks, wired through the skeleton root ref). No console logging — teams that wrap App Layout in their own <ErrorBoundary> keep errors handled quietly, and the signal is a passive DOM query invisible to users.
  • Production positive-control hook. Adds a test-only throwInAppLayoutPart(part) that forces a genuine boundary catch, so a canary can verify — against the real minified prod bundle — that detection still works and hasn't been broken by a build change. It fans out to every mounted boundary for the part, so multiple App Layouts on one page do not clobber each other.

Testing

  • Unit tests in error-boundary.test.tsx: records + exposes errors, throwInAppLayoutPart triggers a real recorded catch, clearAppLayoutErrors, attach no-ops on null and merges (does not clobber) an existing __awsui__, a non-app-layout boundary catch is not recorded, and multi-instance fan-out.
  • Integration tests in widget-areas-error-boundaries.test.tsx that go through the real skeleton-wired App Layout root element: a genuine boundary catch is readable via getAppLayoutErrors(), and throwInAppLayoutPart drives a real catch into the registry.
  • eslint + prettier clean; quick-build clean.

Enables integration/canary tests to detect ONLY errors caught by App Layout
error boundaries, instead of failing on any unexpected console error behind a
hand-maintained allowlist.

- AppLayoutBuiltInErrorBoundary now records each caught error (appLayoutPart +
  message) into a module registry, exposed via a new getErrors accessor on the
  App Layout root element's __awsui__ (attachAppLayoutErrorBoundaryTestHooks).
- Adds a test-only throwInAppLayoutPart hook that forces a genuine boundary
  catch, so a production canary can verify detection survives minification.
- Switches the boundary metric from metrics.sendOpsMetricObject (deduped
  one-time per page) to metrics.sendPanoramaMetric (per-event), making it
  usable for dashboards/alarms and no longer dropping repeat fires.
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.57%. Comparing base (45502c0) to head (63919c1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/error-boundary/internal.tsx 96.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4699   +/-   ##
=======================================
  Coverage   97.57%   97.57%           
=======================================
  Files         948      949    +1     
  Lines       30507    30556   +49     
  Branches    11164    11178   +14     
=======================================
+ Hits        29767    29815   +48     
- Misses        693      694    +1     
  Partials       47       47           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Panorama and Clog are both the legacy console-platform logging path; switching between them is not the TangerineBox migration. TangerineBox metrics live in the internal @amzn/awsui-component-toolkit-internal override, not in OSS components. Revert the metric change and keep the existing sendOpsMetricObject call; the TangerineBox migration will be handled separately on the internal layer.
- Fan-out forced-throw setters (Map<part, Set>) with identity-safe cleanup so multiple app layouts on one page no longer clobber each other's positive-control hook.
- Bound the shared error registry (cap 50).
- Add integration tests that go through the real skeleton-wired app layout root element: a genuine boundary catch is recorded and readable via getAppLayoutErrors, and throwInAppLayoutPart drives a real catch into the registry.
- Trim inline comments to the non-obvious ones.
…controller

- Move the error registry out of a per-realm module global into an ErrorBoundaryController installed on the plugin API. Same-origin frames resolve to the one instance on the top window via findUpApi, so a canary reads getErrors() once at the top document instead of traversing iframes.
- Keep the forced-throw test hook local per window so a positive-control throw never reaches boundaries in other frames.
- Add a direct controller unit test and an api reuse test covering cross-frame aggregation.
@gethinwebster gethinwebster changed the title feat: expose app layout error-boundary catches for canary detection chore: Expose app layout error-boundary catches for canary detection Jul 7, 2026
@gethinwebster gethinwebster marked this pull request as ready for review July 7, 2026 13:04
@gethinwebster gethinwebster requested a review from a team as a code owner July 7, 2026 13:04
@gethinwebster gethinwebster requested review from ernst-dev and removed request for a team July 7, 2026 13:04
@gethinwebster gethinwebster marked this pull request as draft July 7, 2026 13:55
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