GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HTTP2 compatibility layer issues with invalid streams · Issue #29529 · nodejs/node

HTTP2 compatibility layer issues with invalid streams #29529

New issue
Copy link
New issue
Copy link
Closed
Closed
HTTP2 compatibility layer issues with invalid streams#29529
Copy link
Labels
httpIssues and PRs related to the http subsystem.http2Issues and PRs related to the http2 subsystem.streamIssues and PRs related to Node.js streams.

Description

@StephenLynx
StephenLynx
opened on Sep 11, 2019
Issue body actions

https://pastebin.com/LAfzJnQf
Node 12.10, using ssl. The whole code handles both http1 and http2 exactly the same, yet this only happens for ssl using http2.

Activity

Next
  1. mscdex commented on Sep 11, 2019

    @mscdex
    mscdex
    on Sep 11, 2019
    Contributor
    More actions

    It's better to post the details here instead of a link in case the link ever dies.

    Here's the text from the link:

    c/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:132
          throw err;
          ^
     
    Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed
        at Http2ServerResponse.write (internal/http2/compat.js:637:19)
        at GridFSBucketReadStream.<anonymous> (/home/LynxChan/src/be/engine/gridFsHandler.js:304:9)
        at GridFSBucketReadStream.emit (events.js:209:13)
        at addChunk (_stream_readable.js:305:12)
        at readableAddChunk (_stream_readable.js:286:11)
        at GridFSBucketReadStream.Readable.push (_stream_readable.js:220:10)
        at /home/LynxChan/src/be/node_modules/mongodb/lib/gridfs-stream/download.js:250:11
        at /home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:414:17
        at executeCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:406:9)
        at handleCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:128:55)
    Server worker 1 crashed.
    Issues were found  with the templates.
     
    Page boardsPage
    Error, missing element linkOverboard
    Error, missing element linkSfwOver
    Worker 2 booted at Wed, 11 Sep 2019 18:14:54 GMT
    /home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:132
          throw err;
          ^
     
    Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed
        at Http2ServerResponse.write (internal/http2/compat.js:637:19)
        at GridFSBucketReadStream.<anonymous> (/home/LynxChan/src/be/engine/gridFsHandler.js:304:9)
        at GridFSBucketReadStream.emit (events.js:209:13)
        at addChunk (_stream_readable.js:305:12)
        at readableAddChunk (_stream_readable.js:286:11)
        at GridFSBucketReadStream.Readable.push (_stream_readable.js:220:10)
        at /home/LynxChan/src/be/node_modules/mongodb/lib/gridfs-stream/download.js:250:11
        at /home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:414:17
        at executeCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:406:9)
        at handleCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:128:55)
    Server worker 2 crashed.
    
  2. jasnell commented on Sep 11, 2019

    @jasnell
    jasnell
    on Sep 11, 2019
    Member
    More actions

    Hmmm yeah, the http2 streams are handling things a bit more strict than the http1 code. We likely need to relax that in the compatibility layer. /cc @nodejs/http2 @apapirovski

  3. jasnell
    added
    confirmed-bugIssues and PRs for confirmed bugs.
    http2Issues and PRs related to the http2 subsystem.
    and removed
    confirmed-bugIssues and PRs for confirmed bugs.
    on Sep 11, 2019
  4. jasnell commented on Sep 11, 2019

    @jasnell
    jasnell
    on Sep 11, 2019
    Member
    More actions

    Actually, taking the confirmed bug label back off for the time being, want to test a bit more. @StephenLynx can you provide a simple reproduceable test case we can use that demonstrates the problem

  5. StephenLynx commented on Sep 12, 2019

    @StephenLynx
    StephenLynx
    on Sep 12, 2019
    Author
    More actions

    @jasnell Nope. All I got is a report from a person running my software. The information I got is that it happens every now and then after ssl is enabled. Is not the first person to report something similar. My software uses http2 for ssl, I don't run ssl on my own site. Most people end up letting nginx handle ssl, so is not often that people run into issues.
    My software is gitgud.io/LynxChan/LynxChan. The part that touches http2 is https://gitgud.io/LynxChan/LynxChan/blob/2.2.x/src/be/workerBoot.js#L78

  6. sogaani commented on Sep 12, 2019

    @sogaani
    sogaani
    on Sep 12, 2019
    More actions

    This issue might be the same I reported here(second possible reason) and I wrote a reproduceable test case.

  7. StephenLynx commented on Sep 14, 2019

    @StephenLynx
    StephenLynx
    on Sep 14, 2019
    Author
    More actions

    @jasnell can you put back the confirmed bug tag? sogaani just posted a reproduceable test case.

  8. sogaani commented on Sep 15, 2019

    @sogaani
    sogaani
    on Sep 15, 2019
    More actions

    @StephenLynx
    To be sure that the issue you reported and mine are the same, could you check if your software returns 304 or 204 when errors happen?

  9. StephenLynx commented on Sep 15, 2019

    @StephenLynx
    StephenLynx
    on Sep 15, 2019
    Author
    More actions

    @sogaani no, my software just crashes. I pretty much implemented a framework inside the software and I don't take in account the exception thrown by the compatibility layer, so it just crashes.

  10. zandaqo commented on Sep 16, 2019

    @zandaqo
    zandaqo
    on Sep 16, 2019
    More actions

    I also have an issue with 12.10 when I use HTTP2+SSL in production: every now and then the POST request's stream fails to fire end event and just hangs there waiting for more data. It happens unpredictably, no errors are thrown, so I cannot pin point the issue at the moment, but I do know that the stream fires data events and receive all the data but doesn't fire end, error, or frameError events to finish the request. As a workaround for now I just check in data if the received length is equal to the expected length and end the request myself.

    Reacted by Jacob Page and Ali Rahbari
  11. sogaani commented on Sep 17, 2019

    @sogaani
    sogaani
    on Sep 17, 2019
    More actions

    @StephenLynx Then I'm not sure your bug and reproduceable test are the same as mine.
    Before exception,if your software calls res.writeHead(304) or res.writeHead(204), it might be the same.

  12. StephenLynx commented on Sep 17, 2019

    @StephenLynx
    StephenLynx
    on Sep 17, 2019
    Author
    More actions

    @sogaani No, the cause of the crash is a res.write with binary data.

  13. StephenLynx commented on Oct 1, 2019

    @StephenLynx
    StephenLynx
    on Oct 1, 2019
    Author
    More actions

    So, @jasnell what's up?

  14. 18 remaining items

  15. Trott
    added
    httpIssues and PRs related to the http subsystem.
    streamIssues and PRs related to Node.js streams.
    on Dec 15, 2019
  16. ronag
    added a commit that references this issue on Jan 1, 2020

    http2: make HTTP2ServerResponse more streams compliant

    e09aa04
  17. BridgeAR
    added 2 commits that reference this issue on Jan 1, 2020

    http2: make HTTP2ServerResponse more streams compliant

    a1d307f

    http2: make HTTP2ServerResponse more streams compliant

    b916035
  18. DullReferenceException commented on Jan 10, 2020

    @DullReferenceException
    DullReferenceException
    on Jan 10, 2020
    More actions

    I also have an issue with 12.10 when I use HTTP2+SSL in production: every now and then the POST request's stream fails to fire end event and just hangs there waiting for more data. It happens unpredictably, no errors are thrown, so I cannot pin point the issue at the moment, but I do know that the stream fires data events and receive all the data but doesn't fire end, error, or frameError events to finish the request. As a workaround for now I just check in data if the received length is equal to the expected length and end the request myself.

    @zandaqo: I think your message got lost in this issue; it sounds like a different problem than what was originally posted. FWIW, we're having what I think is the exact same issue. I'm still searching to see if there's a different issue focusing on this problem. If you know of where that is, it'd be great to see your workaround.

  19. zandaqo commented on Jan 12, 2020

    @zandaqo
    zandaqo
    on Jan 12, 2020
    More actions

    @DullReferenceException I'm glad you brought it up, I checked recently and the issue is still present in Node 13. As I wrote before, my workaround is terminating requests when the received data length equals the Content-Length header. For raw-body it results in appending a single line to onData function used as a callback for data events:

      function onData(chunk) {
        if (complete) return;
    
        received += chunk.length;
    
        if (limit !== null && received > limit) {
          done(createError(413, 'request entity too large', {
            limit,
            received,
            type: 'entity.too.large',
          }));
        } else if (decoder) {
          buffer += decoder.write(chunk);
        } else {
          buffer.push(chunk);
        }
    
        if (received === length) onEnd();
      }
  20. MylesBorins
    added a commit that references this issue on Jan 30, 2020

    http2: make HTTP2ServerResponse more streams compliant

    f63e440
  21. BethGriggs
    added a commit that references this issue on Feb 6, 2020

    http2: make HTTP2ServerResponse more streams compliant

    92a9dac
  22. Mesteery
    closed this as completedon Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.http2Issues and PRs related to the http2 subsystem.streamIssues and PRs related to Node.js streams.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.