-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nextjs): Add edge route and middleware wrappers #6771
Conversation
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡
|
||
span?.setStatus('internal_error'); | ||
|
||
captureException(objectifiedErr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: passing in the event processor above through capture context might help if we have scope bleeding issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice I like that - 1835aae
/** | ||
* Wraps a Next.js edge route handler with Sentry error and performance instrumentation. | ||
*/ | ||
export function withSentryAPI<H extends EdgeRouteHandler>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Could we get some unit tests for this logic? In particular for the dynamic nature of spanLabel
and spanOp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 76e4815
// We cannot make any assumptions about what users define as their handler except maybe that it is a function | ||
export interface EdgeRouteHandler { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(req: any): any | Promise<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Should we use unknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we have to go with any here because making it unknown would cause TS errors when people pass in their original functions into the wrappers.
*/ | ||
export function withEdgeWrapping<H extends EdgeRouteHandler>( | ||
handler: H, | ||
options: { spanLabel: string; spanOp: string; mechanismFunctionName: string }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: why don't we use spanDescription
instead of spanLabel
here? I think we should keep the span option naming consistent.
Though spans having descriptions and transactions having names is still something I feel we gotta fix somehow.
applies to the other uses as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, agree 924850f
Ref #6120
Ref #4206
This PR adds two wrappers,
withSentryAPI
andwithSentryMiddleware
, to the mini Edge Runtime SDK for Next.js that allow users to wrap their Edge routes and middleware with error and performance instrumentation.