Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 13, 2025
1 parent 57118b7 commit 06f07b9
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,35 @@ export async function getOriginalStackFrames(

let res: Response | undefined = undefined
let reason: string | undefined = undefined
let errored = false
try {
res = await fetch('/__nextjs_original-stack-frames', {
method: 'POST',
body: JSON.stringify(req),
})
} catch (e) {
errored = true
reason = e + ''
}

// When fails to fetch the original stack frames, we reject here to be
// caught at `_getOriginalStackFrame()` and return the stack frames so
// that the error overlay can render.
if (res && (!res.ok || res.status === 204)) {
errored = true // if it's 204 the reason is empty, but we still need to mark as errored
reason = await res.text()
}
if (errored) {
if (res && res.ok) {
const data = await res.json()
return Promise.all(
frames.map((frame) =>
getOriginalStackFrame(frame, {
status: 'rejected',
reason: `Failed to fetch the original stack frames ${reason ? `: ${reason}` : ''}`,
})
)
frames.map((frame, index) => getOriginalStackFrame(frame, data[index]))
)
} else {
if (res) {
reason = await res.text()
}
}

const data = await res.json()
return Promise.all(
frames.map((frame, index) => getOriginalStackFrame(frame, data[index]))
frames.map((frame) =>
getOriginalStackFrame(frame, {
status: 'rejected',
reason: `Failed to fetch the original stack frames ${reason ? `: ${reason}` : ''}`,
})
)
)
}

Expand Down

0 comments on commit 06f07b9

Please sign in to comment.