8000 fix(nextjs): Prevent webpack 5 from crashing server (#3642) · sdemjanenko/sentry-javascript@6c1b4bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c1b4bd

Browse files
authored
fix(nextjs): Prevent webpack 5 from crashing server (getsentry#3642)
It seems that awaiting a flush() call is throwing errors in Webpack 5. This crashes the server as the handler has already sent a response at that point. This patch wraps the flush call in a try, catch until we can figure out a better fix.
1 parent 843bc28 commit 6c1b4bd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/nextjs/src/utils/handlers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
8181

8282
transaction.finish();
8383
}
84-
await flush(2000);
84+
try {
85+
await flush(2000);
86+
} catch (e) {
87+
// no-empty
88+
}
8589
}
8690
};
8791
};

0 commit comments

Comments
 (0)
0