fix: handle Promise.reject case of Sentry.flush in with-sentry example#26767
fix: handle Promise.reject case of Sentry.flush in with-sentry example#26767natterstefan wants to merge 2 commits intovercel:canaryfrom
Conversation
Hi, @natterstefan. I pinged you also in one of the issues you linked, but this should be fixed in getsentry/sentry-javascript#3846. Also, getsentry/sentry-javascript#3811 fixed the await issue with flush. In fact, everything shown in your example, including capturing the exception, is handled by Cheers! |
|
Hi @lobsterkatie, I am sorry it took me some time to answer. Thanks for getting back to me. I tested it with Thanks a lot for taking care of that! |
|
Closed, see #26767 (comment) for more details. |
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-sentryexample does not handle the case whenSentry.flushreturns 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.rejectwhen I read the docs ofSentry.flush. 😅 That took some time to figure that out.The maintainers of
@sentry/nextjsusetry/catchas well -> getsentry/sentry-javascript@6c1b4bd.FTR: So this fixes the example, but it does not fix the issue why
Sentry.flushthrows 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