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

Assertion Error when serving static files with Express #244

Closed
motss opened this issue Jan 23, 2016 · 20 comments
Closed

Assertion Error when serving static files with Express #244

motss opened this issue Jan 23, 2016 · 20 comments

Comments

@motss
Copy link

motss commented Jan 23, 2016

Can it serve static files coupled with Express 4?
I encountered Assertion Error when refreshing the page. However no such issue when using Node's own HTTPS.

require('https') => serving static files without any issues.
require('spdy') => AssertionError.

assert.js:89
  throw new assert.AssertionError({
  ^
AssertionError: false == true
    at PriorityNode.removeChild (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/priority.js:71:3)
    at PriorityNode.remove (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/priority.js:60:15)
    at PriorityTree.add (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/priority.js:153:23)
    at Stream._initPriority (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/stream.js:101:25)
    at new Stream (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/stream.js:75:8)
    at Connection._createStream (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/connection.js:392:16)
    at Connection._handleHeaders (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/connection.js:439:21)
    at Connection._handleFrame (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/connection.js:322:10)
    at Parser.<anonymous> (/home/motss/wotss/serve-static/node_modules/spdy-transport/lib/spdy-transport/connection.js:161:10)
    at emitOne (events.js:77:13)
@indutny
Copy link
Collaborator

indutny commented Jan 23, 2016

This seems to be a bug. May I ask you to reproduce the issue with server running with DEBUG="spdy*" environment variable and gist the logs? I would like to take a look at them.

@indutny
Copy link
Collaborator

indutny commented Jan 23, 2016

Thank you for reporting this.

@motss
Copy link
Author

motss commented Jan 23, 2016

Not sure how much information is needed but I just grabbed as much as I could.
And starting at line 199 is where I refresh the page and at the end of the operation I got the assertion error which you can see at the end of the log.

https://gist.github.com/motss/670faf619b02c37098ec

@erictsangx
Copy link

+1 if keep refreshing the browser. I am using koa.
Briefly inspect the variables, I found the error occurs when child.tree.count > 100(maxCount?)

@indutny
Copy link
Collaborator

indutny commented Jan 25, 2016

@motss thank you for that gist. May I ask you to grab all information from the start? It should be enough to run it in DEBUG="spdy:priority" to reduce amount of actual data.

Thank you!

@indutny
Copy link
Collaborator

indutny commented Jan 25, 2016

@erictsangx yeah, I think it is definitely caused by this somehow...

@indutny
Copy link
Collaborator

indutny commented Jan 25, 2016

@motss nevermind, I know what's causing this.

@indutny
Copy link
Collaborator

indutny commented Jan 25, 2016

Should be fixed now, please run npm update. Sorry about the error!

@erictsangx
Copy link

Unfortunately, I am using v3.2.0, but the problem still occurs:

debug('hit maximum remove id=%d', this.list[0].id);
this.list.shift().remove();
 -> this.parent.removeChild(this);
    -> var index = utils.binarySearch(this.children.list, child, compareChildren);

It is still caused by returning index=-1

@indutny
Copy link
Collaborator

indutny commented Jan 26, 2016

@erictsangx what about spdy-transport which version are you using? (It can be found in npm ls output)

@erictsangx
Copy link

@indutny

├─┬ spdy@3.2.0
│ ├── handle-thing@1.2.4
│ ├── http-deceiver@1.2.4
│ ├── select-hose@2.0.0
│ └─┬ spdy-transport@2.0.10
│   ├── hpack.js@2.1.4
│   ├── obuf@1.1.1
│   ├─┬ readable-stream@2.0.5
│   │ ├── core-util-is@1.0.2
│   │ ├── process-nextick-args@1.0.6
│   │ ├── string_decoder@0.10.31
│   │ └── util-deprecate@1.0.2
│   └─┬ wbuf@1.7.1
│     └── minimalistic-assert@1.0.0

@indutny
Copy link
Collaborator

indutny commented Jan 26, 2016

@erictsangx may I ask you to run it with DEBUG="spdy:priority" environment variable and post all data as a gist (up to the crash).

@motss
Copy link
Author

motss commented Jan 26, 2016

@erictsangx It's fixed for my case. Thanks a lot!

@erictsangx
Copy link

@indutny
https://gist.github.com/erictsangx/01a9826b9ad445e03b5f

I am using a for loop generating push streams to push js files when a user requests index.html.

...
res.end(html);
if (res.push) {
    for (let key of pushMapping.keys()) {
        let stream = res.push(key, {
            request: {
                accept: '*/*'
            },
            response: {
                'content-type': 'application/javascript'
            }
        });
        stream.end(pushMapping.get(key));
    }
}
...

@motss
Copy link
Author

motss commented Jan 26, 2016

@erictsangx May I know how to push files while user is requesting index.html?

@erictsangx
Copy link

@motss A example from the documentation:

spdy.createServer(options, function(req, res) {
  var stream = res.push('/main.js', {
    request: {
      accept: '*/*'
    },
    response: {
      'content-type': 'application/javascript'
    }
  });
  stream.on('error', function() {
  });
  stream.end('alert("hello from push stream!");'); //main.js content (You can use fs to read js files)

  res.end('<script src="/main.js"></script>'); //index.html content
}).listen(3000);

@heavyskyl
Copy link

heavyskyl commented Apr 24, 2017

Have same issue.
Have latest libraries versions.

spdy:priority add node=195 parent=0 weight=256 exclusive=1 +36ms
spdy:priority hit maximum remove id=1 +0ms
spdy:priority add node=197 parent=195 weight=147 exclusive=1 +2ms
spdy:priority hit maximum remove id=2 +0ms

{ AssertionError: false == true
at PriorityNode.removeChild (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/priority.js:72:3)
at PriorityNode.remove (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/priority.js:61:15)
at PriorityTree.add (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/priority.js:157:23)
at Stream._initPriority (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/stream.js:101:25)
at new Stream (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/stream.js:75:8)
at Connection._createStream (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:391:16)
at Connection._handleHeaders (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:438:21)
at Connection._handleFrame (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:321:10)
at Parser. (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:158:10)
at emitOne (events.js:96:13)
at Parser.emit (events.js:191:7)
at readableAddChunk (/usr/src/app/node_modules/readable-stream/lib/_stream_readable.js:217:18)
at Parser.Readable.push (/usr/src/app/node_modules/readable-stream/lib/_stream_readable.js:176:10)
at Parser.Transform.push (/usr/src/app/node_modules/readable-stream/lib/_stream_transform.js:123:32)
at next (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/protocol/base/parser.js:52:12)
at /usr/src/app/node_modules/spdy-transport/lib/spdy-transport/protocol/http2/parser.js:71:5
name: 'AssertionError',
actual: false,
expected: true,
operator: '==',
message: 'false == true',
generatedMessage: true }

Happens when I press f5 several times quickly ( I use push ).

@daviddias
Copy link
Member

Seems that the later issue is also described at:

Let's follow up there.

@deveshmehta7
Copy link

deveshmehta7 commented Sep 20, 2018

Just use the below package.
Here we have removed the assertion error
AssertionError: false == true

"spdy": "https://github.com/deveshmehta7/node-spdy#assertionError",

@Kuvalda
Copy link

Kuvalda commented Oct 4, 2018

Have same problem, server crash periodically when reload page...
"spdy": "^3.4.7",
"stream": "0.0.2",
"tls": "0.0.1",

GET /static/css/app.a1b9783855251f1ac0b945889157e0e8.css 304 2.073 ms - -
assert.js:42

throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: false == true

at PriorityNode.removeChild (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/priority.js:74:3)


at PriorityNode.remove (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/priority.js:62:15)


at PriorityTree.add (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/priority.js:163:23)


at Stream._initPriority (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/stream.js:101:25)


at new Stream (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/stream.js:76:8)


at Connection._createStream (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:388:16)


at Connection._handleHeaders (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:436:21)


at Connection._handleFrame (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:319:10)


at Parser.<anonymous> (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/connection.js:156:10)


at emitOne (events.js:116:13)


at Parser.emit (events.js:211:7)


at addChunk (/usr/src/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_readable.js:291:12)


at readableAddChunk (/usr/src/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_readable.js:278:11)


at Parser.Readable.push (/usr/src/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_readable.js:245:10)


at Parser.Transform.push (/usr/src/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_transform.js:148:32)


at next (/usr/src/app/node_modules/spdy-transport/lib/spdy-transport/protocol/base/parser.js:53:12)

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

No branches or pull requests

7 participants