unit: Cannot serve css/js static files big size
I always get the following error:
2024/01/15 17:53:41 [error] 49#52 *103 file "/var/www/html/public/vendor/telescope/app.css" has changed while sending response to a client
2024/01/15 17:53:41 [error] 49#52 *104 file "/var/www/html/public/vendor/telescope/app.css" has changed while sending response to a
telescope/app.css" has changed while sending response to a client
This file size is 147kb, but if I try to load a css in the same directory with size of 1kb, it works fine. My config file:
{
"listeners":{
"*:80":{
"pass":"routes"
}
},
"routes": [
{
"match": {
"uri": "!/index.php"
},
"action": {
"share": "/var/www/html/public$uri",
"fallback": {
"pass": "applications/laravel"
}
}
}
],
"applications": {
"laravel": {
"type": "php",
"root": "/var/www/html/public/",
"script": "index.php"
}
}
}
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 44 (24 by maintainers)
Commits related to this issue
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to ac000/unit by ac000 5 months ago
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to ac000/unit by ac000 5 months ago
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to ac000/unit by ac000 5 months ago
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to ac000/unit by ac000 5 months ago
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to ac000/unit by ac000 5 months ago
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to ac000/unit by ac000 5 months ago
- HTTP: Remove short read check in nxt_http_static_buf_completion() On GH, @tonychuuy reported an issue when using Units 'share' action they would get the following error in the unit log 2024/01/15 ... — committed to nginx/unit by ac000 5 months ago
Someone on Reddit appears to have had a the same issue. While they don’t mention they’re running Unit, the error message is identical so I suspect they are: https://www.reddit.com/r/docker/comments/tjomqm/file_has_changed_while_sending_response_to_a/
@tonychuuy
Thanks for your help in debugging this issue. This fix will appear in the next release of Unit, 1.32
OK, so I was able to reproduce this locally by exporting a directory into a QEMU/KVM virtual machine running Fedora using the 9P protocol via
In the guest I mounted it thus
Note I set the msize to 65512
After pointing Unit to this directory and executing (in the guest)
Where tfile is a file of 149922 bytes in length, I got the expected failure
And looking at the strace output
We got the request from the client, opened the requested file and stat’d it…
We asked to read 131072 bytes but only got 61440
At which point the check in unit that if we read less then we asked for kicks in and aborts the transfer…
Now trying it with the above patch which removes that check
All good, lets check the strace output
Again, we got the request from the client, opened the requested file and stat’d it (oh and just to be clear, we stat(2) the file to get its size).
So, now we do two reads totalling 80290 bytes and send that back to the client along with some headers.
We do another two reads (giving a total of 149922 bytes read) and send that to the client and that’s us done.
This was certainly a fun one to debug 😉
I’ll turn the patch into a PR…
@ac000 @tonychuuy it works for me having the files inside the Linux filesystem outside the mounted windows shares. So taking 9P out will solve it. Testing more
cli inside WSL ubuntu
From your
Interesting that it again only read 65512 bytes, same as when you tried the css file.
Your initial 1MiB file test worked I assume because it was being served out of tmpfs which is effectively RAM.
OK, so you’re using WSL 2, I think I’ve read that it uses the 9p filesystem protocol, which is a network protocol, which could perhaps explain why you’re seeing short reads…
Need to try and devise some way of testing that theory…
Using the top option from docker and applying strace outside docker works for the test: