-
-
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
ref(nextjs): [Experiment] Automatically wrap API route handlers #3469
Conversation
size-limit report
|
We will ship the manual approach today #3462 |
0311c28
to
de5b4d8
Compare
Woof heroic effort. Makes me think this is a shortcoming with NextJS and not so much a Sentry problem. If they had a dev friendly way of defining groups of API routes and wrapping handlers, then we wouldn't need this kind of workaround to inject wrappers. |
This is out of date and whatever we decide to do here, we should start from the current version of the SDK, using this for reference if it turns out to be useful. Closing. |
This PR uses webpack to wrap API request handlers in a try/catch, so that errors can be reported to Sentry. Currently, that wrapping must be done manually, using
withSentry
. This makes that process automatic.The current implementation is pretty hacky - definitely open to suggestions of a better way. Regardless, here's how it works:
*Unfortunately, in order to instantiate a
Module
object to use to do the compilation, we need the code we pass it to use commonJS-style imports, which there's no guarantee it does. So before we pass it to our loader, we run it through Babel, using a Babel plugin specifically designed for that exact transformation.