fix(nuxt): check for H3 error cause before re-capturing#18035
Merged
fix(nuxt): check for H3 error cause before re-capturing#18035
Conversation
s1gr1d
approved these changes
Oct 24, 2025
c6d6925 to
97f1621
Compare
logaretm
added a commit
that referenced
this pull request
Dec 4, 2025
This is the opposite of the flake that happened in #18035, so apparently nuxt-3 flaky tests started after merging that PR. It looks like the same problem, we have a race condition, if Nitro catches the error first when executing the middleware handler it will be swallowed by an H3 error but it seems the `instanceof` check isn't being satisfied in this case, so perhaps with Nuxt 3, there isn't a unified H3 instance or perhaps we are using a different one for the check. I will take a better look later, this is a band-aid to stop this from randomly failing our PRs. I couldn't reproduce this locally at all tho. If we don't like this relaxation we can close this PR and I can spend more time on this, I thought the most important thing here is we do capture an error with the critical information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The flakey tests in nuxt-4 pointed out that we have a race condition where a middleware error can bubble up as an H3 event error, which wraps the original error we caught.
This means the
checkOrSetAlreadyCaughtwon't actually detect it since it doesn't check the.causeproperty.I added the logic needed for that for the Nuxt SDK but feels like this may come up later if it hadn't already.
Note that this does not affect the spans created, just the mechanism of the caught error, the spans would still be marked correctly as errored.