-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Getting ERR_STREAM_WRITE_AFTER_END after #4139 #4151
Comments
Hey, thank you for reporting. This might be Blitz configuring the request in a special way, since we are reaching in pretty heavily into the internals to access request data. To confirm that the issue is caused by #4139, could you check if A reproduction of some kind would be a huge help for us to get a head start on debugging - but no worries if you can't share it, we can take a look. @lobsterkatie ping to get your thoughts here as well. |
Yep, I'm trying to get a reduced example for you to look at. I've swapped through the versions of |
Okay, I've figured out the cause. One of my API routes had this code in it: res.json(pullResponse);
res.end(); Which is redundant, because That said: I can just yank the second line from ^ that example, and it works fine. So this is more of a bug that turns non-ideal code from symptomless to very symptomful, depending on how you think about the guarantees around |
We should aim to either address this, or document as a limitation. Thanks for investigating @tmcw! |
I just want to add that I got this error as well on an api endpoints that pipes a file response. Basically I just request a file from a url and pipe that response to the |
We're getting the same error with a next.js API route that adds authentication headers and proxies the request to a third party api endpoint. We were able to resolve the issue by removing
|
Stumbled on this today. Found this interesting monologue in the sentry source:
I have some cases where I call .end() after .json().. removing the .end() "fixes" the issue. But just like @bunea I also pipe a file through NextApiResponse. Not sure how to tackle this yet, removing |
The file I was trying to pass via a pipe to the I was using the |
You're a real life saver we had a Nextjs api handler which piped down a pdf file wrapped in withSentry this was crashing our server and was a real head scratcher thanks to your comment we solved it just wanted to say thanks! |
Is the Sentry team looking for a contributed PR, or working on a fix? This bug has rather major impact - it hard-crashes apps with an internal and hard to track down exception in Node.js internals - and has been in the wild for a few months now. My application at least is pinning Sentry indefinitely because I'd rather have less accurate traces than hard crashes in production. |
Next 12.0.10 or close to, appears to demand newer sentry/nextjs version, or nothing works at all. |
hi @tmcw we are always happy if someone can help out with a contribution! I can understand this is an issue for quite some folks in this thread and possibly elsewhere we will try to escalate it internally. If that is to help with reviewing a PR for the fix we could that as well. |
Hey, all. Sorry this has been dangling. I think at this point the lesser of two evils is to back out the original change, rather than try to find a hack to fix the hack, or try to find a different solution to the original problem, given that it seems non-trivial and I'm not sure we have the resources to address it right now. I'll try to get that done in the next few days. After that, if someone wants to take a stab at fixing the original problem (next expects |
…ue (#4516) In #4139, a change was introduced in order to suppress a false positive warning thrown by nextjs, by setting `res.finished` to `true` just long enough for nextjs to check it and decide no warning was needed. In simple cases, it worked just fine, but in some set-ups the "just long enough for nextjs to check it and calm down" turned out to also be "just long enough for other things to check it and get mad." This backs out that change, as it seems it's doing more harm than good. In order to address the original problem (documented in [1] and [2]), a new warning is added, explaining that the false positive is just that. Not as elegant as suppressing the message altogether, but it should tide us over until such time as we're able to try again with a different approach. Fixes #4151. [1] #3852 [2] #4007
…4706) In the nextjs SDK, when we wrap users' API routes, we also wrap the response's `end` method, in order to keep the lambda running the route handler alive long enough to send events to Sentry. As a consequence, however, Next thinks a response hasn't been sent at all, because `end` hasn't been called within the timeframe that it expects, so it throws a warning in dev. A previous attempt[1] to fix this problem backfired[2], and had to be reverted[3], so as a compromise option for the moment, we log a warning about the Next warning, so at least people know it's nothing to worry about. Some people are finding this behavior spammy[4], though, so this PR adds an env variable check which allows a user to suppress our meta-warning, and also improves the warning itself so that people know the option is there. [1] #4139 [2] #4151 [3] #4516 [4] #3852 (comment)
FYI, this is still an issue for us, and appeared to start after we upgraded from We're using the latest Sentry & Next.js:
And our handlers are wrapped like this:
We're running on Vercel and our logs are full of errors like this (reformatted for readability):
Since this is flooding our logs I've removed |
for me too, this is making the dev environment crashing. The issue appears also removing the |
This is happening to us as well - can we get this reopened? Or should we submit a new issue? |
@jessehansen could you open a new issue with your nextjs, node, and webpack versions, as well as your next config, sentry config and information about your deploy set up? |
This is still a problem, brought down our prod There's no next: "12.2.3", next.config.js:
|
This error keeps cropping up for me too on new versions. It's pretty frustrating: digging through the Sentry code, there's still a bunch of code overriding the meaning of |
@AbhiPrasad Please consider reopening this issue per your earlier comment:
|
Reopening this issue as there is still work to be done here. |
This comment suggests that this might be caused by Does anyone have a minimal reproduction of this since I can't reproduce it with a basic nextjs app. |
Also, please let us know if you are running on Vercel or not - that will help a lot with debugging! |
Yes, running on Vercel. Not using Apollo Server. |
We're running in a DigitalOcean droplet, not Vercel |
We're running in Google Cloud Run, have a docker container running a custom Node express server with Next on top |
I'm going to close this as a duplicate of #6099 since this issue has been closed once before when it was first fixed and these two issues appear to be identical. |
Package + Version
@sentry/next-js
Version:
Description
Hi! I'm using Sentry with a Blitzjs stack, which is a mildly abstracted version of Next.js. Generally, the Next.js sentry module works very well, but after 6.14.3, I experienced crashes on any request in prod:
This is noted in the PR itself, and appears to not affect Next.js in some configurations, but clearly affects my relatively vanilla setup of Blitz running on Render (and the bug also appears locally). I'll try to figure out if this is purely a Blitz-level occurrence or something that manifests in Render on serverful non-Lambda environments as well. I've set up the
externalResolver
option as suggested to avoid the error message that this PR attempts to fix systematically.The text was updated successfully, but these errors were encountered: