forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(after): broken error handling for unstable_after(promise) (vercel…
…#71373) In vercel#71231 we've added `onAfterTaskError`, which is intended for handling errors that happened within `unstable_after` (currently only used to fail the build if anything is thrown during prerendering). It was being called correctly for the callback form, `unstable_after(() => { ... })`, but we missed the fact that `unstable_after(promise)` is also valid, and weren't calling it for rejected promises. (Apparently we also weren't printing any kind of error message for those, and it's been that way since the start. my bad.) This PR unifies the error handling for callbacks and promises.
- Loading branch information
1 parent
19a5f7d
commit 3cfd255
Showing
7 changed files
with
111 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
.../app-dir/next-after-app-static/build-time-error/app/page-throws-in-after/promise/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react' | ||
import { unstable_after as after } from 'next/server' | ||
import { setTimeout } from 'timers/promises' | ||
|
||
export const dynamic = 'error' | ||
|
||
export default function Index() { | ||
const promise = (async () => { | ||
await setTimeout(500) | ||
throw new Error( | ||
'My cool error thrown inside unstable_after on route "/page-throws-in-after/promise"' | ||
) | ||
})() | ||
after(promise) | ||
return <div>Page with after()</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...app-dir/next-after-app-static/build-time-error/app/route-throws-in-after/promise/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { unstable_after as after } from 'next/server' | ||
import { setTimeout } from 'timers/promises' | ||
|
||
export const dynamic = 'error' | ||
|
||
export async function GET() { | ||
const promise = (async () => { | ||
await setTimeout(500) | ||
throw new Error( | ||
'My cool error thrown inside unstable_after on route "/route-throws-in-after/promise"' | ||
) | ||
})() | ||
after(promise) | ||
return new Response() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters