Skip to content

Commit 4d070a2

Browse files
authored
feat: update Koa docs (#7500)
1 parent be5a489 commit 4d070a2

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/platforms/node/guides/koa/index.mdx

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,24 @@ Sentry.init({
6868
});
6969

7070
const requestHandler = (ctx, next) => {
71-
return new Promise((resolve, reject) => {
72-
Sentry.runWithAsyncContext(async () => {
73-
const hub = Sentry.getCurrentHub();
74-
hub.configureScope((scope) =>
75-
scope.addEventProcessor((event) =>
76-
Sentry.addRequestDataToEvent(event, ctx.request, {
77-
include: {
78-
user: false,
79-
},
80-
})
81-
)
82-
);
83-
84-
try {
85-
await next();
86-
} catch (err) {
87-
reject(err);
88-
}
89-
resolve();
90-
});
71+
Sentry.runWithAsyncContext(() => {
72+
const hub = Sentry.getCurrentHub();
73+
hub.configureScope((scope) =>
74+
scope.addEventProcessor((event) =>
75+
Sentry.addRequestDataToEvent(event, ctx.request, {
76+
include: {
77+
user: false,
78+
},
79+
})
80+
)
81+
);
82+
83+
next();
9184
});
9285
};
9386

9487
// this tracing middleware creates a transaction per request
95-
const tracingMiddleWare = async (ctx, next) => {
88+
const tracingMiddleWare = (ctx, next) => {
9689
const reqMethod = (ctx.method || "").toUpperCase();
9790
const reqUrl = ctx.url && stripUrlQueryAndFragment(ctx.url);
9891

@@ -130,7 +123,7 @@ const tracingMiddleWare = async (ctx, next) => {
130123
});
131124
});
132125

133-
await next();
126+
next();
134127
};
135128

136129
app.use(requestHandler);

0 commit comments

Comments
 (0)