Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure
withSentry
reports API (serverless) errors from Vercel
Potential fix for getsentry#3917 to ensure Sentry error reporting clean-up is done -- transaction finished and error flushed -- when run from a Vercel deployment, by explicitly calling the clean-up code in two places: directly from the `withSentry` handler wrapper function, as well as the existing monkey-patched `res.end()`. In Vercel the `res.end()` function is not (or is not always) called, which means the prior approach that relied on monkey-patching of that function for clean-up did not work in Vercel. Note 1: this is a naive fix: I'm not sure why res.end() isn't called as expected or if there might be a better target for monkey- patching. Note 2: a new `__flushed` variable is used to avoid running the clean-up code twice, should both the explicit and the monkey-patched path be run. See the TODO asking whether this flag should be set at the beginning, instead of the end, of the clean-up function `finishTransactionAndFlush()`
- Loading branch information