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

[🐛 BUG]: Static middleware causes ERR_CONTENT_LENGTH_MISMATCH #1593

Closed
1 task done
tux-rampage opened this issue Jun 6, 2023 · 13 comments · Fixed by roadrunner-server/send#62
Closed
1 task done
Assignees
Labels
B-bug Bug: bug, exception P-HTTP Plugin: HTTP
Milestone

Comments

@tux-rampage
Copy link

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

I configured an application as follows:

version: "2.7"

server:
  command: "php /app/backend/roadrunner.php"

logs:
  mode: development
  encoding: console
  level: info

rpc:
  listen: tcp://127.0.0.1:6001

http:
  address: 0.0.0.0:3000
  access_logs: true
  raw_body: false
  pool:
    debug: true

  middleware:
    - static
    - sendfile
    - headers

  uploads:
    dir: /var/uploads
    forbid:
      - ".php"
      - ".exe"
      - ".bat"
      - ".sh"
  headers:
    response:
      X-Powered-By: "roadrunner/php"

  static:
    dir: /app/public/dist/de
    calculate_etag: false
    response:
      X-RoadRunner-Source: Static

For some resources that will be served by the static middleware (identified by the header X-RoadRunner-Source from the config above), the browser rejects the resource with ERR_CONTENT_LENGTH_MISMATCH (webkit) or NS_ERROR_NET_PARTIAL_TRANSFER (firefox).

grafik

This does not happen for all files, some are served without any problems, while others are broken. The only difference that i can currently spot is the file size. It seems to happen when a file exceeds 16k. Could this be a buffer problem?

Version (rr --version)

  • rr version 2023.1.4 (build time: 2023-05-25T11:10:19+0000, go1.20.4), OS: linux, arch: amd64
  • rr version 2.12.2 (build time: 2023-01-12T12:07:45+0000, go1.19.5), OS: linux, arch: amd64

How to reproduce the issue?

See yaml in the description

Relevant log output

No response

@rustatian
Copy link
Member

Hey @tux-rampage 👋🏻
Interesting, I think that this is the ServeContent limitation but I'll dig into that. Thanks for the report 👍🏻

@rustatian
Copy link
Member

BTW, could you try to remove the Accept-Ranges: bytes header, since this middleware doesn't support that header?

@tux-rampage
Copy link
Author

BTW, could you try to remove the Accept-Ranges: bytes header, since this middleware doesn't support that header?

How should I do that? I did not configure that and RR seems to send it from the Middleware (Those are the response headers).

@rustatian
Copy link
Member

Oh, yeah. Could you try then to use just plain curl request, w/o browser? I think, when I saw this header, that RR tries to respond with some of the Ranges headers.

@tux-rampage
Copy link
Author

Sure. In the meantime for completeness, here are the Request headers. I just needed to strip some private information:
grafik

@tux-rampage
Copy link
Author

All right, same issue with a CURL request:

> curl --verbose -s http://localhost/styles.css -o /dev/null; echo "Exit Code: $?"
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /styles.css HTTP/1.1
> Host: localhost
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 82399
< Content-Type: text/css; charset=utf-8
< Last-Modified: Tue, 06 Jun 2023 08:09:44 GMT
< X-Powered-By: roadrunner/php
< X-Roadrunner-Source: Static
< Date: Tue, 06 Jun 2023 10:09:43 GMT
< 
{ [16863 bytes data]
* transfer closed with 65536 bytes remaining to read
* Closing connection 0
Exit Code: 18

@rustatian
Copy link
Member

Ok, thanks for this investigation 👍🏻 I'll write a tests with a big static file to confirm this and then dig into the problem. I thinks this is a http server limitation and I would be able to raise the limits. Expected fix should be this Thursday in v2023.1.5.

@tux-rampage
Copy link
Author

Awesome. Thanks for the quick reaction 👍

@rustatian
Copy link
Member

Funny thing here, if you copy the file curl ... -o some_file (instead of /dev/null) it would be of the correct size and correct content.

@rustatian
Copy link
Member

rustatian commented Jun 6, 2023

@tux-rampage Are you using nginx or some web-server in front of the RR ?

@rustatian
Copy link
Member

@tux-rampage Found the bug. Could you please remove the send middleware and retry the request?

@rustatian rustatian added this to General Jun 7, 2023
@github-project-automation github-project-automation bot moved this to Backlog in General Jun 7, 2023
@rustatian rustatian added this to the v2023.1.5 milestone Jun 7, 2023
@rustatian rustatian moved this from Backlog to Unreleased in General Jun 7, 2023
@rustatian rustatian added P-HTTP Plugin: HTTP and removed F-need-verification labels Jun 7, 2023
@rustatian rustatian mentioned this issue Jun 8, 2023
6 tasks
@rustatian rustatian moved this from Unreleased to Done in General Jun 8, 2023
@tux-rampage
Copy link
Author

Hi @rustatian

Thanks for the quick solution. I have retested it with v2023.1.5 and can confirm that this issue is solved. 👍🏻

@rustatian
Copy link
Member

Hey @tux-rampage 👋🏻 Cool, nice to hear that ⚡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-bug Bug: bug, exception P-HTTP Plugin: HTTP
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants