Skip to content
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

NodeJs v8 stream.push() after EOF #60

Closed
Eldar-X opened this issue May 31, 2017 · 44 comments
Closed

NodeJs v8 stream.push() after EOF #60

Eldar-X opened this issue May 31, 2017 · 44 comments

Comments

@Eldar-X
Copy link

Eldar-X commented May 31, 2017

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)

@tuananh
Copy link

tuananh commented Jun 2, 2017

Confirmed. I get this issue with Node v8 as well.

@tuananh
Copy link

tuananh commented Jun 8, 2017

Anyone taking this? Can someone point me to where I should look?

@tuananh
Copy link

tuananh commented Jun 8, 2017

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.

@andykant
Copy link

andykant commented Jun 9, 2017

This still occurs in Node v8.1.0.

@niftylettuce
Copy link
Contributor

Same issue, v8.0.0

@tuananh
Copy link

tuananh commented Jun 13, 2017

@jonathanong could you please take a look?

@jonathanong
Copy link
Member

i've seen this before. i haven't investigated it yet. it is one of the blockers for me to upgrading to node 8.

@tuananh
Copy link

tuananh commented Jun 20, 2017

anyone found a fix for this? also, is there an alternative middleware?

@Eldar-X
Copy link
Author

Eldar-X commented Jun 20, 2017

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())

@jonathanong
Copy link
Member

is it because you are using Z_SYNC_FLUSH? what happens if you don't use a flush parameter?

@jonathanong
Copy link
Member

e50d15f seems okay to me.

anyone else have any ideas?

@Eldar-X
Copy link
Author

Eldar-X commented Jun 20, 2017

@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.

@jonathanong
Copy link
Member

okay, i think the time i saw this error was with v8.0.0. i don't see it anymore with the latest node

@tuananh
Copy link

tuananh commented Jun 21, 2017

It seems 8.1.2 fixes it. Any idea what causes this in the first place?

@pastelsky
Copy link

Still experiencing this in 8.1.2. I don't have conditional-get middleware.

@Eldar-X
Copy link
Author

Eldar-X commented Jun 21, 2017

I have same issue in 8.1.2 but with conditional-get middleware. I see this issue once more when my stream was broken.

@jonathanong
Copy link
Member

can anyone make a PR with a failing test casE?

@mcollina
Copy link

Can you check if nodejs/node#13850 this solves the issue?

@andykant
Copy link

andykant commented Jul 6, 2017

Node 8.1.3 fixes the issue.

@tuananh
Copy link

tuananh commented Jul 6, 2017

8.1.3 works for me as well

@jonathanong
Copy link
Member

closing. thanks @mcollina !

@Eldar-X
Copy link
Author

Eldar-X commented Jul 10, 2017

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

@mrchief
Copy link

mrchief commented Jul 12, 2017

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.

@mcollina
Copy link

I'll be happy to have a look, if you can post an example to reproduce the issue consistently.

@Eldar-X
Copy link
Author

Eldar-X commented Jul 12, 2017

@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

  1. 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.

@mrchief
Copy link

mrchief commented Jul 12, 2017

@mcollina My setup is bit complicated but @Eldar-X setup will do.

@mcollina
Copy link

@Eldar-X @mrchief I cannot reproduce with node 8.1.2, 8.1.3, 8.1.4 or master using your example on Mac OS X 10.11 and Chrome.

@mrchief
Copy link

mrchief commented Jul 13, 2017

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.

@Eldar-X
Copy link
Author

Eldar-X commented Jul 13, 2017

@mcollina i am also on Mac Os 10.11

tem-13-2017 20-17-07

@Eldar-X
Copy link
Author

Eldar-X commented Jul 13, 2017

@mcollina
Copy link

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.

@mcollina
Copy link

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.

@mcollina
Copy link

I can reproduce by loading the server with autocannon:

autocannon -H Accept-Encoding=gzip -c 100 -d 5 localhost:3000

mcollina added a commit to mcollina/node that referenced this issue Jul 17, 2017
If the stream is destroyed while the transform is still being
applied, push() should not be called, and the internal state
should be cleared.

See: koajs/compress#60
@mcollina
Copy link

Here is the fix: nodejs/node#14330

mcollina added a commit to nodejs/node that referenced this issue Jul 19, 2017
If the stream is destroyed while the transform is still being
applied, push() should not be called, and the internal state
should be cleared.

See: koajs/compress#60
PR-URL: #14330
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@refack
Copy link

refack commented Jul 19, 2017

Will you be adding a regression test for this? Then maybe apply for addition to node's CitGM

Fishrock123 pushed a commit to Fishrock123/node that referenced this issue Jul 20, 2017
If the stream is destroyed while the transform is still being
applied, push() should not be called, and the internal state
should be cleared.

Refs: koajs/compress#60
PR-URL: nodejs#14330
Backport-PR-URL: nodejs#14396
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>

 Conflicts:
	lib/zlib.js
@mcollina
Copy link

This should be definitely fixed in Node 8.2.1.

@refack
Copy link

refack commented Jul 21, 2017

@jonathanong if you could write a regression test for this. It's literally keeping up at night 😨

@jonathanong
Copy link
Member

@refack im not sure what the test case is...

@refack
Copy link

refack commented Jul 22, 2017

@dominictobias
Copy link

I have it on 8.10.0 on windows

@mcollina
Copy link

@dominictobias can you please confirm that #60 (comment) can be used to reproduce the problem?

@dominictobias
Copy link

dominictobias commented Mar 14, 2018

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 😳

@dandradesg
Copy link

npm cache clean --force

@rimiti
Copy link

rimiti commented Jul 18, 2018

In my case, after making a npm cache clean --force, everything works again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests