Skip to content

Commit eb0023c

Browse files
committed
refactor(qwik)!: remove public useErrorBoundary hook
<ErrorBoundary> is now the single public error-boundary surface. The store-provider hook is kept as an internal helper, renamed `useErrorBoundaryContext` (shared by the component and the test boundaries) and no longer exported; the orphaned ErrorBoundaryStore type is also made internal. Updates the devtools hook registry and docs accordingly.
1 parent f8edbe0 commit eb0023c

18 files changed

Lines changed: 17 additions & 139 deletions

File tree

.changeset/errorboundary-to-core.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
`ErrorBoundary` now ships from `@qwik.dev/core` instead of `@qwik.dev/router` — update your imports. It also changes behavior:
77

88
- **`fallback$` is now required.**
9+
- The `useErrorBoundary()` hook is **removed**`<ErrorBoundary>` is the single error-boundary surface.
910
- It catches errors only from **its own subtree**: the **closest** boundary handles an error, instead of every boundary on the page reacting to the global `qerror` event.
1011
- It now catches render throws during **SSR** (rendering `fallback$` in place), not just on the client.

packages/devtools/kit/src/protocol/hooks.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const HOOK_GROUPS = {
99
'useStyles',
1010
'useStylesScoped',
1111
'useConstant',
12-
'useErrorBoundary',
1312
'useSerializer',
1413
'useServerData',
1514
'useLocation',

packages/devtools/kit/src/protocol/protocol.unit.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ describe('devtools protocol', () => {
116116
'useStyles',
117117
'useStylesScoped',
118118
'useConstant',
119-
'useErrorBoundary',
120119
'useSerializer',
121120
'useServerData',
122121
'useLocation',
@@ -141,7 +140,6 @@ describe('devtools protocol', () => {
141140
'useStyles',
142141
'useStylesScoped',
143142
'useConstant',
144-
'useErrorBoundary',
145143
'useSerializer',
146144
'useServerData',
147145
'useLocation',

packages/devtools/plugin/src/parse/__snapshots__/parse.test.ts.snap

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ exports[`injectCollectHooks > matches snapshot of transformed output 1`] = `
2323
useSerializer$,
2424
useConstant,
2525
useOn,
26-
useServerData,
27-
useErrorBoundary
26+
useServerData
2827
} from '@qwik.dev/core';
2928
import { _getDomContainer, isServer, useVisibleTask$ } from '@qwik.dev/core/internal';
3029
import type { QRL, Signal } from '@qwik.dev/core';
@@ -81,14 +80,6 @@ export default component$<ButtonProps>((props) => {
8180
data: serverData
8281
});
8382
84-
const errorBoundary = useErrorBoundary();
85-
collecthook({
86-
variableName: 'errorBoundary',
87-
hookType: 'useErrorBoundary',
88-
category: 'VariableDeclarator',
89-
data: errorBoundary
90-
});
91-
9283
const location = useLocation();
9384
collecthook({
9485
variableName: 'location',
@@ -386,7 +377,6 @@ export default component$<ButtonProps>((props) => {
386377
<div>Context: {context.theme} - {context.size}</div>
387378
<div>Button ID: {buttonId}</div>
388379
<div>Constant: {constantValue}</div>
389-
{errorBoundary.error && <div>Error captured</div>}
390380
<div>ServerData: {serverData ? JSON.stringify(serverData) : 'N/A'}</div>
391381
<div>Serialized N: {customSerialized.value.n}</div>
392382
<Resource

packages/devtools/plugin/src/parse/parse.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const sampleVarDecl = `
2323
useSerializer$,
2424
useConstant,
2525
useOn,
26-
useServerData,
27-
useErrorBoundary
26+
useServerData
2827
} from '@qwik.dev/core';
2928
import { _getDomContainer, isServer, useVisibleTask$ } from '@qwik.dev/core/internal';
3029
import type { QRL, Signal } from '@qwik.dev/core';
@@ -52,7 +51,6 @@ export default component$<ButtonProps>((props) => {
5251
const signal = useSignal<any>('111');
5352
const constantValue = useConstant(() => 'CONST');
5453
const serverData = useServerData<any>('demo-key');
55-
const errorBoundary = useErrorBoundary();
5654
const location = useLocation();
5755
const navigate = useNavigate();
5856
const content = useContent();
@@ -203,7 +201,6 @@ export default component$<ButtonProps>((props) => {
203201
<div>Context: {context.theme} - {context.size}</div>
204202
<div>Button ID: {buttonId}</div>
205203
<div>Constant: {constantValue}</div>
206-
{errorBoundary.error && <div>Error captured</div>}
207204
<div>ServerData: {serverData ? JSON.stringify(serverData) : 'N/A'}</div>
208205
<div>Serialized N: {customSerialized.value.n}</div>
209206
<Resource

packages/devtools/ui/src/features/RenderTree/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const HOOK_TYPES = [
2525
'useConstant',
2626
'useComputed',
2727
'useAsyncComputed',
28-
'useErrorBoundary',
2928
'useServerData',
3029
'useSerializer',
3130
'useLocation',

packages/docs/src/routes/api/qwik/api.json

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -672,20 +672,6 @@
672672
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/error/error-boundary.ts",
673673
"mdFile": "core.errorboundaryprops.md"
674674
},
675-
{
676-
"name": "ErrorBoundaryStore",
677-
"id": "errorboundarystore",
678-
"hierarchy": [
679-
{
680-
"name": "ErrorBoundaryStore",
681-
"id": "errorboundarystore"
682-
}
683-
],
684-
"kind": "Interface",
685-
"content": "```typescript\nexport interface ErrorBoundaryStore \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n$fallback$?\n\n\n</td><td>\n\n\n</td><td>\n\n(error: any) =&gt; unknown\n\n\n</td><td>\n\n_(Optional)_ The boundary's fallback renderer. Set by `<ErrorBoundary>` so SSR can render the fallback in place of a subtree that throws during server render (on the client the boundary re-renders instead). Internal — not meant to be set by application code.\n\n\n</td></tr>\n<tr><td>\n\nerror\n\n\n</td><td>\n\n\n</td><td>\n\nany \\| undefined\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
686-
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/error/error-handling.ts",
687-
"mdFile": "core.errorboundarystore.md"
688-
},
689675
{
690676
"name": "event$",
691677
"id": "event_",
@@ -2580,20 +2566,6 @@
25802566
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-context.ts",
25812567
"mdFile": "core.usecontextprovider.md"
25822568
},
2583-
{
2584-
"name": "useErrorBoundary",
2585-
"id": "useerrorboundary",
2586-
"hierarchy": [
2587-
{
2588-
"name": "useErrorBoundary",
2589-
"id": "useerrorboundary"
2590-
}
2591-
],
2592-
"kind": "Function",
2593-
"content": "```typescript\nuseErrorBoundary: () => ErrorBoundaryStore\n```\n**Returns:**\n\n[ErrorBoundaryStore](#errorboundarystore)",
2594-
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-error-boundary.ts",
2595-
"mdFile": "core.useerrorboundary.md"
2596-
},
25972569
{
25982570
"name": "useId",
25992571
"id": "useid",

packages/docs/src/routes/api/qwik/index.mdx

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,61 +1670,6 @@ Rendered in place of the subtree when a descendant throws during render. Lazily
16701670
16711671
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/error/error-boundary.ts)
16721672
1673-
<h2 id="errorboundarystore">ErrorBoundaryStore</h2>
1674-
1675-
```typescript
1676-
export interface ErrorBoundaryStore
1677-
```
1678-
1679-
<table><thead><tr><th>
1680-
1681-
Property
1682-
1683-
</th><th>
1684-
1685-
Modifiers
1686-
1687-
</th><th>
1688-
1689-
Type
1690-
1691-
</th><th>
1692-
1693-
Description
1694-
1695-
</th></tr></thead>
1696-
<tbody><tr><td>
1697-
1698-
$fallback$?
1699-
1700-
</td><td>
1701-
1702-
</td><td>
1703-
1704-
(error: any) =&gt; unknown
1705-
1706-
</td><td>
1707-
1708-
_(Optional)_ The boundary's fallback renderer. Set by `<ErrorBoundary>` so SSR can render the fallback in place of a subtree that throws during server render (on the client the boundary re-renders instead). Internal — not meant to be set by application code.
1709-
1710-
</td></tr>
1711-
<tr><td>
1712-
1713-
error
1714-
1715-
</td><td>
1716-
1717-
</td><td>
1718-
1719-
any \| undefined
1720-
1721-
</td><td>
1722-
1723-
</td></tr>
1724-
</tbody></table>
1725-
1726-
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/error/error-handling.ts)
1727-
17281673
<h2 id="event_">event$</h2>
17291674
17301675
```typescript
@@ -9708,18 +9653,6 @@ void
97089653
97099654
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-context.ts)
97109655
9711-
<h2 id="useerrorboundary">useErrorBoundary</h2>
9712-
9713-
```typescript
9714-
useErrorBoundary: () => ErrorBoundaryStore;
9715-
```
9716-
9717-
**Returns:**
9718-
9719-
[ErrorBoundaryStore](#errorboundarystore)
9720-
9721-
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-error-boundary.ts)
9722-
97239656
<h2 id="useid">useId</h2>
97249657
97259658
```typescript

packages/docs/src/routes/docs/(qwik)/core/overview/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ Note the `string extends C`, this is only true when TypeScript cannot infer the
550550

551551
- [`$()`](../../advanced/qrl/index.mdx) - creates a QRL
552552
- [`noSerialize()`](/docs/core/state/#noserialize)
553-
- `useErrorBoundary()`
554553
- [`qwikVite()`](../../advanced/vite/index.mdx#qwikvite) - entry point for qwik with vite
555554

556555
### Components
557556

558557
- [`<Slot>`](../slots/index.mdx) - declares a content projection slot
559558
- [`<Suspense>`](/docs/labs/suspense/index.mdx) - shows fallback UI while part of the page waits
559+
- [`<ErrorBoundary>`](/api/qwik/#errorboundary) - renders a fallback when a descendant throws
560560
- `<SSRStreamBlock>` - declares a stream block
561561
- `<SSRStream>` - declares a stream
562562
- `<Fragment>` - declares a JSX fragment

packages/docs/src/routes/docs/labs/suspense/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ Props:
587587

588588
`<Suspense>` only handles content that is still loading. It does not catch errors thrown by child components.
589589

590-
For errors thrown by descendants, reach for [`useErrorBoundary()`](/api/qwik/#useerrorboundary).
590+
For errors thrown by descendants, reach for [`<ErrorBoundary>`](/api/qwik/#errorboundary).
591591

592592
## Choosing the Right Primitive
593593

0 commit comments

Comments
 (0)