Skip to content

Commit

Permalink
Add code comments (#58529)
Browse files Browse the repository at this point in the history
The code comments added in 2dc0ba4 are missing somehow. These are very necessary to understand the code as it looks confusing.
  • Loading branch information
shuding authored Nov 16, 2023
1 parent 32875e4 commit ce97390
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/next/src/server/app-render/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,17 @@ export async function handleAction({
if (isFetchAction) {
res.statusCode = 500
await Promise.all(staticGenerationStore.pendingRevalidates || [])

const promise = Promise.reject(error)
try {
// we need to await the promise to trigger the rejection early
// so that it's already handled by the time we call
// the RSC runtime. Otherwise, it will throw an unhandled
// promise rejection error in the renderer.
await promise
} catch {}
} catch {
// swallow error, it's gonna be handled on the client
}

return {
type: 'done',
Expand Down Expand Up @@ -608,8 +615,14 @@ To configure the body size limit for Server Actions, see: https://nextjs.org/doc
if (isFetchAction) {
const promise = Promise.reject(err)
try {
// we need to await the promise to trigger the rejection early
// so that it's already handled by the time we call
// the RSC runtime. Otherwise, it will throw an unhandled
// promise rejection error in the renderer.
await promise
} catch {}
} catch {
// swallow error, it's gonna be handled on the client
}
return {
type: 'done',
result: await generateFlight(ctx, {
Expand All @@ -629,8 +642,14 @@ To configure the body size limit for Server Actions, see: https://nextjs.org/doc
await Promise.all(staticGenerationStore.pendingRevalidates || [])
const promise = Promise.reject(err)
try {
// we need to await the promise to trigger the rejection early
// so that it's already handled by the time we call
// the RSC runtime. Otherwise, it will throw an unhandled
// promise rejection error in the renderer.
await promise
} catch {}
} catch {
// swallow error, it's gonna be handled on the client
}

return {
type: 'done',
Expand Down

0 comments on commit ce97390

Please sign in to comment.