cloudflare-next-intl 0.9.37 → 0.9.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/src/error_handling/index.d.ts +0 -1
- package/dist/src/error_handling/index.js +0 -1
- package/dist/src/error_handling/report_client_error_action.js +2 -2
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/dist/src/error_handling/error_handling_action_config.d.ts +0 -3
- package/dist/src/error_handling/error_handling_action_config.js +0 -7
package/README.md
CHANGED
|
@@ -627,6 +627,34 @@ server-side resolution) on `ErrorHandlingParams` — reporting is skipped
|
|
|
627
627
|
whenever `consent` is set and not `true`, since sending error reports to a
|
|
628
628
|
third party without consent can itself be GDPR-relevant.
|
|
629
629
|
|
|
630
|
+
#### Reporting client-side errors
|
|
631
|
+
|
|
632
|
+
`reportClientError` is a ready-made server action for a client component's
|
|
633
|
+
own `catch`/error boundary — it resolves your `errorHandling`/`generate`
|
|
634
|
+
config through `@intl-config` (the alias `db`/`clearSessionAction` already
|
|
635
|
+
use — see "Setup" above), so there's no wrapper file or setup call beyond
|
|
636
|
+
that alias:
|
|
637
|
+
|
|
638
|
+
```typescript
|
|
639
|
+
// some_client_component.tsx
|
|
640
|
+
"use client";
|
|
641
|
+
import reportClientError from "cloudflare-next-intl/reportClientError";
|
|
642
|
+
|
|
643
|
+
try {
|
|
644
|
+
await riskyClientThing();
|
|
645
|
+
} catch (error) {
|
|
646
|
+
void reportClientError(error, "riskyClientThing");
|
|
647
|
+
}
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
The error is stringified before it crosses the action boundary — no need to
|
|
651
|
+
normalize it into an `Error` yourself first, even a non-`Error` throw or an
|
|
652
|
+
unresolved React reference stub comes through safely — and `isClient: true`
|
|
653
|
+
plus a best-effort `requestContext: { path, userAgent, referer }` (via
|
|
654
|
+
`next/headers`) are attached automatically. Prefer `createServerErrorAction`
|
|
655
|
+
instead if you want config bound explicitly per call rather than resolved
|
|
656
|
+
through `@intl-config`.
|
|
657
|
+
|
|
630
658
|
#### Stale Deploy & Chunk Load Error Recovery
|
|
631
659
|
|
|
632
660
|
When a new version of your application is deployed to Cloudflare Workers, users on older client sessions may encounter `ChunkLoadError` or failed dynamic imports when requesting outdated chunks.
|
|
@@ -10,5 +10,4 @@ export { defaultIgnoredConsoleErrors } from './default_ignored_console_errors.js
|
|
|
10
10
|
export { default as isStaleDeployError, defaultStaleDeployPatterns, setStaleDeployPatterns, getStaleDeployPatterns, } from './is_stale_deploy_error.js';
|
|
11
11
|
export { default as clearClientCache } from './clear_client_cache.js';
|
|
12
12
|
export { default as useStaleDeployRecovery, shouldRecoverFromStaleDeploy } from './use_stale_deploy_recovery.js';
|
|
13
|
-
export { setErrorHandlingActionConfig, getErrorHandlingActionConfig } from './error_handling_action_config.js';
|
|
14
13
|
export type { ErrorHandlingParams, ErrorHandlingRoutingConfig } from '../types/types.js';
|
|
@@ -8,4 +8,3 @@ export { defaultIgnoredConsoleErrors } from './default_ignored_console_errors.js
|
|
|
8
8
|
export { default as isStaleDeployError, defaultStaleDeployPatterns, setStaleDeployPatterns, getStaleDeployPatterns, } from './is_stale_deploy_error.js';
|
|
9
9
|
export { default as clearClientCache } from './clear_client_cache.js';
|
|
10
10
|
export { default as useStaleDeployRecovery, shouldRecoverFromStaleDeploy } from './use_stale_deploy_recovery.js';
|
|
11
|
-
export { setErrorHandlingActionConfig, getErrorHandlingActionConfig } from './error_handling_action_config.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use server';
|
|
2
|
-
import
|
|
2
|
+
import config from '@intl-config';
|
|
3
3
|
import { reportClientErrorCore } from './report_client_error_core.js';
|
|
4
4
|
export default async function reportClientError(error, classOrMethodName, params) {
|
|
5
|
-
await reportClientErrorCore(
|
|
5
|
+
await reportClientErrorCore(config, error, classOrMethodName, params);
|
|
6
6
|
}
|
package/llms.txt
CHANGED
|
@@ -34,6 +34,7 @@ other subpath can be used.
|
|
|
34
34
|
- `./clearClientCache` — `clearClientCache()`: async helper wiping `window.caches`, unregistering service workers, and clearing `sessionStorage` for recovering from stale deployments.
|
|
35
35
|
- `useStaleDeployRecovery(error, onRecover?, delayMs?)` (client hook, in `./errorHandling`) — once per build id (`localStorage['buildId']`, `sessionStorage` marker), waits `delayMs` (default 5000ms), runs optional `onRecover()` + `clearClientCache()` in parallel, then `window.location.reload()`. Returns whether a reload is pending, so caller renders a loading state instead of error UI. Recovers even past the one-reload cap when `localStorage['buildIdSetAt']` is <60s old (new deploy still settling). `shouldRecoverFromStaleDeploy(error, buildId, marker, recentBuild?)` and `isRecentBuild(setAt, now, windowMs?)` are the pure predicates.
|
|
36
36
|
- `./createServerErrorAction` — `createServerErrorAction(action, config)`: wrapper for server actions with standardized error reporting.
|
|
37
|
+
- `./reportClientError` — `reportClientError(error, classOrMethodName, params?)`: ready-made `"use server"` action reporting a client-originated error, config resolved via `@intl-config` (no per-app wrapper file or setup call needed, unlike `createServerErrorAction`).
|
|
37
38
|
|
|
38
39
|
## `firebaseAuth*` subpaths (require `firebaseAuth` set on your `RoutingConfig`)
|
|
39
40
|
|
package/package.json
CHANGED