fix: handle Promise.reject case of Sentry.flush in with-sentry example #26767
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note
It took me hours to figure out why I was getting an "Internal Server Error" when I added Sentry to our Next-Vercel setup based on "with-sentry".
I prepared examples in my demo repo here: natterstefan/next-with-sentry#2 with one deployment with and one without the
try/catch
.The
with-sentry
example does not handle the case whenSentry.flush
returns a rejected Promise. I was not aware of that as well until I read getsentry/sentry-javascript#3691 (comment).In my opinion, one problem lies in the description of
Sentry.flush
:I did not think of handling
Promise.reject
when I read the docs ofSentry.flush
. 😅 That took some time to figure that out.The maintainers of
@sentry/nextjs
usetry/catch
as well -> getsentry/sentry-javascript@6c1b4bd.FTR: So this fixes the example, but it does not fix the issue why
Sentry.flush
throws an error/rejects. 🤔Edit: There are comments mentioning the issue with
Sentry.flush
: getsentry/sentry-javascript#3643 (comment), and getsentry/sentry-javascript#3746. Let's see if they handle it (announced here) or not.Documentation / Examples