Skip to content

Make the shipping error boundary render its fallback - #637

Merged
addyosmani merged 1 commit into
addyosmani:mainfrom
rudycelekli:fix/error-boundary-20261003
Oct 10, 2026
Merged

addyosmani merged 1 commit into
addyosmani:mainfrom
rudycelekli:fix/error-boundary-20261003

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Problem and change

The shipping skill’s error-boundary example reads this.state.hasError without initializing state, so it crashes even when its children are healthy. It also has no getDerivedStateFromError, leaving componentDidCatch to report the error without selecting the fallback.

Initialize the state and implement the fallback lifecycle, following React’s error-boundary contract. The reporting fields and retry callback remain intact.

Reproduction

I extracted the exact TypeScript/JSX example, transpiled it, and mounted it with React 19.2.0, ReactDOM 19.2.0 and jsdom. Before the change, both controls fail with Cannot read properties of null (reading 'hasError'). After the change:

  • Healthy children render, and no error is reported.
  • A controlled child-rendering error shows the fallback and reports the original error, child stack, user and page.
  • Clicking retry after the child recovers renders the child again without adding an error report.

Dropping the new lifecycle method makes the failing-child control fail again. This is a DOM runtime check, not a browser-engine test or a paid model-behavior evaluation.

Verification

  • Node 24.19.0 on macOS: the existing 173 tests passed with no skips.
  • All five validators passed; routing passed 141 checks with 89/89 rank-1 positives at the unchanged 95% floor.
  • Bash cache controls 29/29, ignore controls 49/49, and session-start payload passed.
  • No skill description, trigger prompt, model instruction, or catalog entry changed. The rejection ledger has no prior entry for this example, and no open PR touches this skill.
  • Linux/Windows and plugin-install checks will be reported by hosted CI; they are not claimed as locally run.

AI assistance: OpenAI Codex / GPT-6 was used for investigation and the patch.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>

@addyosmani addyosmani left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: I rendered the sample as written and it throws on every render, even with a healthy child, because state is never initialised, and without getDerivedStateFromError the fallback can never show. This is the canonical fix. Merging.

suggestion (non-blocking): the class is still an untyped React.Component, so strict TypeScript flags this.props.children. Typing the props would make the sample copy-paste clean, if you want a follow-up.

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.

2 participants