We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7330344 commit d8cf291Copy full SHA for d8cf291
packages/nextjs/src/utils/handlers.ts
@@ -20,7 +20,10 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
20
local.add(req);
21
local.add(res);
22
23
- local.run(async () => {
+ // `local.bind` causes everything to run inside a domain, just like `local.run` does, but it also lets the callback
24
+ // return a value. In our case, all any of the codepaths return is a promise of `void`, but nextjs still counts on
25
+ // getting that before it will finish the response.
26
+ const boundHandler = local.bind(async () => {
27
try {
28
const currentScope = getCurrentHub().getScope();
29
@@ -87,5 +90,7 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
87
90
}
88
91
89
92
});
93
+
94
+ return await boundHandler();
95
};
96
0 commit comments