Skip to content

Response body ends prematurely #803

Description

@ronag

Haven't had time to check but I suspect we might have a problem with body sizes larger than 31 bit.

undici will complete without error before reading entire response body.

Activity

  1. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    @dnlup would you mind taking a look and maybe making a test?

  2. added this to the 4.0 milestone on May 11, 2021
  3. mcollina commented on May 11, 2021

    @mcollina
    SponsorMember

    How does Node.js handle this case?

  4. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    It just works. This might be a wasm thing.

  5. dnlup commented on May 11, 2021

    @dnlup
    Contributor

    Are we talking about something greater than Number.MAX_SAFE_INTEGER?

  6. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    Are we talking about something greater than Number.MAX_SAFE_INTEGER?

    No, I have a case where I'm unable to receive anything larger than ~2^31. I'm not sure if it's undici at the moment but I think it's good idea to have a test where we transfer more than 2^32 bytes.

  7. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    Could also be a problem with Node 16 http1/http2 server. I'm seeing the issue in a reverse proxy in production.

  8. dnlup commented on May 11, 2021

    @dnlup
    Contributor

    Inspecting llhttp I see content-length is an unsigned int of 64 bits. That should exclude some issues in the parser native side.

  9. dnlup commented on May 11, 2021

    @dnlup
    Contributor

    I think the problem is with Node. It happens only if you pass the entire buffer to res.write. Undici errors with message The other side closed.

    I used Node 16 to test.

  10. reopened this on May 11, 2021
  11. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    Something is weird. undici always prematurely ends response at 1605405800 bytes without error. While curl properly reads all 5 GB.

  12. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    @mcollina @dnlup

    This fails: #805

  13. ronag commented on May 11, 2021

    @ronag
    MemberAuthor

    @mcollina we should probably fix this before release.

  14. 14 remaining items

  15. indutny commented on May 12, 2021

    @indutny
    Member

    Sounds like wasm2wat

  16. ronag commented on May 12, 2021

    @ronag
    MemberAuthor

    What's the best way to view the contents of the wasm file?

    Maybe https://webassembly.studio?

  17. indutny commented on May 12, 2021

    @indutny
    Member

    I know what's going on. Could you find s_n_llhttp__internal__n_consume_content_length replace size_ts with uint64_ts right after it and try recompiling and running the test?

  18. ronag commented on May 12, 2021

    @ronag
    MemberAuthor

    That fixed it!

  19. indutny commented on May 12, 2021

    @indutny
    Member

    Alright, working on the real fix. Thanks for trying it.

  20. indutny commented on May 12, 2021

    @indutny
    Member

    Fix: nodejs/llparse#44 .

    @ronag could you try llhttp.c from the attachment and see if it still works?

    llhttp.c.zip

  21. indutny commented on May 12, 2021

    @indutny
    Member

    FWIW, this is the file that I intend to release once llparse fix lands. Feel free to ship the wasm version built from this file (after reviewing the diff) until we'll get it pushed upstream!

  22. ronag commented on May 12, 2021

    @ronag
    MemberAuthor

    Fix: nodejs/llparse#44 .

    @ronag could you try llhttp.c from the attachment and see if it still works?

    llhttp.c.zip

    All good!

  23. dnlup commented on May 12, 2021

    @dnlup
    Contributor

    Thank you for the help @indutny !

  24. indutny commented on May 12, 2021

    @indutny
    Member
  25. indutny commented on May 12, 2021

    @indutny
    Member
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

    Status: help-wantedThis issue/pr is open for contributionsbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions