NodeJs v8 stream.push() after EOF
Eldar-X opened this issue ยท 44 comments
After upgrade to v8 i got error in console
Error: stream.push() after EOF at readableAddChunk (_stream_readable.js:227:30) at Gzip.Readable.push (_stream_readable.js:195:10) at Gzip.Transform.push (_stream_transform.js:151:32) at Zlib.callback (zlib.js:430:16)
Confirmed. I get this issue with Node v8 as well.
Anyone taking this? Can someone point me to where I should look?
Notice node 8.1 fixes something in zlib. Is this related?
A regression in the Zlib module that made it impossible to properly subclasses zlib.Deflate and other Zlib classes has been fixed. [6aeb555cc4] #13374.
This still occurs in Node v8.1.0.
Same issue, v8.0.0
@jonathanong could you please take a look?
i've seen this before. i haven't investigated it yet. it is one of the blockers for me to upgrading to node 8.
anyone found a fix for this? also, is there an alternative middleware?
In my case, i found solution by changing order of compress and conditional-get middleware
app.use(compress({
flush: require('zlib').Z_SYNC_FLUSH
}))
.use(conditional())
.use(etag())
is it because you are using Z_SYNC_FLUSH
? what happens if you don't use a flush parameter?
e50d15f seems okay to me.
anyone else have any ideas?
@jonathanong without flush parameter i have same result but if koa-compress middleware over conditional-get middleware everything okay. Looks like this issue happening only when we use conditional-get middleware.
okay, i think the time i saw this error was with v8.0.0
. i don't see it anymore with the latest node
It seems 8.1.2 fixes it. Any idea what causes this in the first place?
Still experiencing this in 8.1.2. I don't have conditional-get
middleware.
I have same issue in 8.1.2 but with conditional-get middleware. I see this issue once more when my stream was broken.
can anyone make a PR with a failing test casE?
Can you check if nodejs/node#13850 this solves the issue?
Node 8.1.3 fixes the issue.
8.1.3 works for me as well
closing. thanks @mcollina !
node v8.1.3 still same issue
const app = new Koa();
const conditional = require('koa-conditional-get');
const etag = require('koa-etag');
const compress = require('koa-compress');
const serveStatic = require('koa-static');
app.use(conditional())
app.use(etag())
app.use(compress())
app.use(serveStatic('public'))
app.use(async(ctx, next) => {
ctx.type = 'text/html';
ctx.body = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="/test.css">
</head>
<body>
Response OK
</body>
</html>`;
})
app.listen(3000)
Don't forget to include test css with some content to public dir
I don't use conditional get or etag and still see this issue (with node 8.1.3 and even using Z_SYNC_FLUSH). I'm using koa-webpack middleware though.
I'll be happy to have a look, if you can post an example to reproduce the issue consistently.
@mcollina you can try my example only install deps and run this app then visit page and reload it! After reloading you can see this message in your console
- I am using Marko.js and i streaming response to ctx.body but if i have error in my template file i also see this error message.
Could the OS be a factor? I'm on Windows 7 x64. Even in my setup, I don't get it consistently. E.g., I ran my app right now and there were no errors. Then I refreshed the page and saw this error. And sometimes it happens many times within the same request.
I'll try to upload my setup tonight.
https://github.com/Eldar-X/koa-issue my simple setup
Confirmed, this is still happening. Quite interestly enough, this does not happen with CURL. I'll see if I can track this down (it might take a while).
It seems a different one than nodejs/node#13850.
Now I cannot reproduce anymore. However, the same node version/code was showing the problem while I was traveling (and I could not work on it). If someone has a consistent way of reproducing this problem, please let me know.
I can reproduce by loading the server with autocannon:
autocannon -H Accept-Encoding=gzip -c 100 -d 5 localhost:3000
Here is the fix: nodejs/node#14330
Will you be adding a regression test for this? Then maybe apply for addition to node's CitGM
This should be definitely fixed in Node 8.2.1.
@jonathanong if you could write a regression test for this. It's literally keeping up at night
@refack im not sure what the test case is...
@jonathanong this might help https://github.com/nodejs/node/pull/14330/files
I have it on 8.10.0 on windows
@DominicTobias can you please confirm that #60 (comment) can be used to reproduce the problem?
Ah don't worry, I speed read on a number of issues and this is a general problem with npm cache and windows, rather than something koa specific
npm cache clean --force
In my case, after making a npm cache clean --force
, everything works again.