Commit 517f0e0
authored
Expose TS type for onRequestError (#67859)
## What
Expose the TS types for onRequestError API
### API
```ts
type RequestErrorContext = {
routerKind: 'Pages Router' | 'App Router';
routePath: string;
routeType: 'render' | 'route' | 'action' | 'middleware';
renderSource?: 'react-server-components' | 'react-server-components-payload' | 'server-rendering';
};
export declare namespace Instrumentation {
type onRequestError = (error: unknown, errorRequest: Readonly<{
method: string;
url: string;
headers: NodeJS.Dict<string | string[]>;
}>, errorContext: Readonly<RequestErrorContext>) => void | Promise<void>;
```
### Usage
```ts
// instrumentation.ts
import { type Instrumentation } from 'next'
export const onRequestError: Instrumentation.onRequestError = (
err,
request,
context
) => {
//...
}
```1 parent 8f08c7c commit 517f0e0
File tree
3 files changed
+14
-2
lines changed- packages/next/src
- server/instrumentation
- test/e2e/on-request-error/basic
3 files changed
+14
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
4 | 10 | | |
5 | | - | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | 14 | | |
| |||
0 commit comments