Problem/Motivation
After a migration from Drupal 9.5.11on to 10.2.2 on OVH mutualized server, the document is not loaded, JS files are not running and the error err_http2_protocol_error error is diplayed in the console.
Please feel free to move this question to another Drupal place if needed.
Steps to reproduce
I'm migrating Drupal 9.5.11 to 10.2.2 on
- a mutualized OVH,
- Apache2
- PHP 8.2
- Mysql
- Https
- With ssl on PROD
- Without ssl on PReprod
I'm notifiying that the behavior is the same on PREPROD and PROD. The production has been rolled back on Drupal 9.5.11 and is working well. The migrated website on local is working well.
An issue is showing in the console: <site url> net:err_http2_protocol_error
After having configured $settings['file_assets_path'], the css and js are well loaded in the network panel, but the issue <site url> net:err_http2_protocol_error is still displayed in the console, the CSS are OK, but JS files are not working.
As many posts are talking about the browsers versions, extensions …, I've updated all my browsers, as said in this example:https://kinsta.com/knowledgebase/err_http2_protocol_error/
In Firefox:
all the assets are well loaded but not the main document:
All the assets are loaded in less than 100ms.
The main document is loaded in 9349ms.
Is it the main reason why the error net:err_http2_protocol_error appears ?
Before the migration, in Drupal 9.5.1, the main page was loaded in 871s and the website is well working.
In Chromium:
The network is showing every assets loaded but not the main document 325B (6.10s), 140,09ko.
- The CSS are loaded and applied.
- The JS files are loaded but aren't applyable. Some animations are missing.
In last version, the network is showing a heavier document, 31.3KB, for 805ms and the website is working well.
Who would have encountered the same behaviour or have a solution for this ?
This migration is not valid.
Thank you by advance. Regards.
| Comment | File | Size | Author |
|---|---|---|---|
| Firefox_heavy.png | 258.12 KB | frondeau |
Issue fork drupal-3419024
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3419024-binary-file-response
changes, plain diff MR !6453
Comments
Comment #2
cilefen commentedThere are assets system changes in Drupal 10. Did you have an opportunity to review the release notes?
Comment #3
cilefen commentedI made this a support request so we can gather more information.
Comment #4
frondeau commentedHello @Cilefen,
Thank you for your feedback.
Which pages would reply to my issue, please, ?
Would you post the concerned urls ?
Thank you by advance,
Regards;
Comment #5
frondeau commentedComment #6
frondeau commentedComment #7
cilefen commentedI don’t remember ever having seen it with Drupal. See also https://stackoverflow.com/questions/58215104/whats-the-neterr-http2-prot...
Comment #8
troesler commentedI have the same problem with OVH :
Here is my test url : https://drupal1022.monsitedev.com
You may see the error on Chrome on the front page
I spended hours of researches and tests in vain, so if a kind soul is willing to solve this problem, I will be forever grateful!
Comment #9
mably commentedSame problem here, Drupal 10.2.2 on PHP 8.1.
Is any solution available?
EDIT: Looks like the content-length header on gzipped CSS and JS assets is incorrect (uncompressed size?).
Comment #10
cilefen commentedAlso OVH?
Comment #11
cilefen commentedThere is a lot of debugging advice in https://stackoverflow.com/questions/58215104/whats-the-neterr-http2-prot.... If you haven’t done those things you haven’t done everything.
Comment #12
mably commentedIt looks like Drupal sends an invalid "content-length" header for JS and CSS gzipped assets on first load.
Disabling gzip using
SetEnv no-gzip 1in my.htaccessfile fixes the problem, but that's not really a solution.Comment #13
longwave@mably if you can reliably reproduce that with a set of steps that would be really helpful, as we can turn it into a test case.
Comment #14
frondeau commentedHello all,
Thank you for your feed backs, I fell less alone ;-)
I can confirm that there is a difference between D9 and D10.2.2 as there is a Content-Length in the header, reporting the file size.
It' seems that in my case, the docment has a size of 32KB.
All the other files are loaded from memory (0KB) or heavy less equals 5.5KB.
Is Content-Length usefull ?
If so, what would happen if the code set it to -1?
Thanks by advance.
Comment #15
longwaveContent-Length was added to fix other issues: https://www.drupal.org/node/3298551
However perhaps this is now incorrectly calculated in the case of gzipped content?
Comment #16
frondeau commented@Cilefen,
About the link you're sharing, https://stackoverflow.com/questions/58215104/whats-the-neterr-http2-protocol-error-about, many answers are talking about the environment size and the cpu, but in my case, the website is about 2% of the disk size, and the memory is not full used neither.
As the error message is about HTTP/2, it seems to be due to the protocol, so maybe the answer would be about the header, woudn't it ?
Comment #17
frondeau commentedThank you for your feedback @longwave, I guess the subject is Content-Length too.
Comment #18
catchComment #19
cilefen commented@frondeau
Wrong content-length header is mentioned a lot at https://stackoverflow.com/questions/58215104/whats-the-neterr-http2-prot.... There are many possible answers.
Comment #20
catchI've opened an MR with a potential fix - to just stop adding the content length header for BinaryFileResponse (which is what the first asset request returns). Would be great if people experiencing this issue on OVH could try it out (at least once we've had a green test run here). We should probably add some minimum test coverage to the existing content length tests to make sure files are skipped too.
Can you confirm that asset aggregates are actually getting written and this problem is only for the first request that builds them? After that they should be served as actual files and would expect it to work again.
If the server gzips the response from Drupal, it should also be responsible for updating the content length header, so this is perhaps mis-configuration on OVH's side? But also don't feel that we have a strong use case for setting the content length header for binary files and if we can save people hours/days of fruitless debugging that would be good.
Comment #22
mably commentedThe proposed fix doesn't seem to work on my side.
Looks like we never go through the related code when generating aggregated CSS and JS.
But may be I'm doing something wrong.
Comment #23
frondeau commentedHi @catch,
Thank you for your MR.
I can't test this MR as it is pull from 11.x.
But I could test if you create a MR on 10.2.2, on a real website.
Would you have any time to repeat it on this version, please ?
Thank you by advance.
Comment #24
frondeau commentedComment #25
catch@frondeau you should be able to use the diff from https://git.drupalcode.org/project/drupal/-/merge_requests/6453.diff with a 10.2.x site, the affected code is identical.
Comment #26
cilefen commented@frondeau I don't understand your question. The diff, https://git.drupalcode.org/project/drupal/-/merge_requests/6453.diff, applies to the 10.2.x branch as well as to version 10.2.2.
Comment #27
frondeau commented@catch,
thanks for the dif.
after having applyed the patch, cleared the browsers cache, cleared Drupal caches, the issue is still the same, on the document: "
Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR"Document Content-Lenght: 138720
Content-Encoding: gzip
Additional information:
On the first page load, the error is displayed on css_* and js_* and document.
On the second page reload: the message is displayed only on document while all the assets are loaded from memory.
Comment #28
catchCan you try temporarily disabling CSS and JavaScript aggregation (admin/config/development/performance) and let us know if you still see the same error anywhere? If so, then this isn't specific to BinaryFileResponse at all and could be a much wider problem with the content length header.
Comment #29
cilefen commentedThis is probably due to how HTTP/2 multiplexes.
Comment #30
frondeau commentedHi @catch, @cilefen,
I've removed the aggregation of css/js.
Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR" is still displayed on the document file.FYI, I've already tested the front theme with a standard one as Claro and the message is displayed too.
Comment #31
frondeau commentedThanks for your answer, @alexpott,
I'll prepare some debug messages to check the ContentLength handle and give a feedback on the conversation..
Comment #32
frondeau commentedHi all,
Before adding logs in Drupal 10.2.2, I've created another migration with Drupal 10.1.8.
This version seems to work well at first sight:
Some functional tests will follow to confirm, but it is promising as this.
How can we solve the error "
Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR" version 10.2.2 ?Comment #33
Okita974 commentedHi,
I have exactly the same problem as you with the same configuration. Strangely, there's no problem when I'm logged in, only when I'm anonymous.
Comment #34
MiniDream commentedHi i have the same problem as you on 10.2 after a migration from 9.5.. and im on OVH too
to add more information, i got the same error on some ajax update request such as custom batch step who need me manualy refresh the page to see what batch update.. and somme other custom ajax request ending the same way...
Comment #35
longwaveI wonder if this is the same as the issue described at https://github.com/symfony/symfony/issues/46449#issuecomment-1140985890 - which also related to Drupal and the Content-Length header on OVH hosting.
It appears that
zlib.output_compressionis not enabled on OVH but perhaps they are doing something else to compress content which means Content-Length is incorrect.A non-Drupal issue where the solution is also to unset the Content-Length header on OVH: https://help.nextcloud.com/t/shared-hosting-ovh-web-nextcloud-issue-with...
Anyone affected by this can try adding this to their .htaccess:
Comment #36
frondeau commentedHi all,
thank you to have reported the solution @longwave.
Your proposition
Header always unset Content-Lengthin your comment https://www.drupal.org/project/drupal/issues/3419024#comment-15431735 is working for me on Drupal 10.2.2.Would you update the .htaccess file to add this option for the "
OVH case" or "net::err_http2_protocol_error" ?Regards.
Comment #38
catchHid the MR because that was a complete red herring.
@frondeau Drupal's .htaccess file is intended to be modifiable, we won't add OVH-specific information in there since it could get confusing for sites that don't run into this problem.
However we could add this information to the change record for the issue that added the content length header and/or Drupal 10.2.0 release notes as a known issue.
Comment #39
MiniDream commentedHi Everyone, #35 @longwave work for me too.
Comment #40
mably commented#35 seems to also fix some stability problems when running locally on Docker (Drupal 10.2.3, PHP 8.3, Apache with Nginx proxy).
Comment #41
frondeau commented@catch,
I agree with you to avoid the comment ot include "OVH" term but this solution could be added as comment with a title of type "In case of ContentLength issue"
As a comment, it could provide a direct solution for the developers.
A information about it in the release notes should be good too. Thanks.
Regards.
Comment #42
mlzr#35 + issue https://www.drupal.org/project/drupal/issues/3432990 works for me.
1. Set 'Header always unset Content-Length' in the .htaccess AND
2. Patch /public_html/core/lib/Drupal/Core/StackMiddleware/ContentLength.php #48:
From: $response->headers->set('Content-Length', strlen($content), TRUE);
To: $response->headers->set('Content-Length', strlen($content)+2, TRUE);
Thanks @longwave and the referrer to issues #3432990
Marcel
Comment #43
michelrrr commentedThanks #35 !!
My config was :
OVH
10.1.8 ALL FINE, no problem
10.2.5 migration => HTTP/2 with net::err_http2_protocol_error + slowness
Solved by adding 'Header always unset Content-Length' in .htaccess of www
This community is awesome ;)
Comment #44
fred r commented#35 work for me too on OVH
Comment #45
sweepchild commentedHi everyone!
It was an image upload issue on my side and got errors. First patched like below; the error gone, uploaded successfully.
But then some http2 protocol errors appeared on XHR requests. After billion attempts, changed the patch like (switching from +2 to +1) and errors gone forever.
Comment #46
sneo commentedSame error for me with 10.3.2.
With #35 the loading of my Js continue, but i can have some slowness for some page.
It' very visible because the first image to be loaded is a 50px of width (then the correct image is loaded ) Some page may took 1sec or more to complete load properly.
So for me, it's not really a complete solution.
All was fine on my Dev server (Nginx) but as soon i migrate to an OVH performance ... Issues on chrome.
Does anyone had the same issue on another environment ?
Edit: it seems that when the slowness occur is when ressources are loaded on after the other. Not in parallel. So if there is a lot of JS ressources, it took way longer :)
Comment #47
mkolar commentedSame issue on AWS using CloudFront, Load balancer and WAF (not sure where is a problem, on D9 it was ok). Currently trying to update to 10.2.4 and got this error..
Comment #48
jasonsafro commentedI wrote a patch for a content-length issue I encountered. I'm not sure if the issues are related but here's the other issue: https://www.drupal.org/project/drupal/issues/3494148
Comment #49
nicolas bouteille commentedHello,
Same here:
OVH performance
D 10.4.1
PHP 8.1.29
#35 solves it for me as well thanks!
However, my .htaccess is not versionned and re-created by core-composer-scaffold on every composer install... how do you suggest I apply this fix? How do you guys handle it?
Comment #50
tostinni commented@nicolas bouteille you can use this in your
composer.jsonto patch it during scafolding :And then you put this code in
patches/drupal/3419024.txtComment #51
nicolas bouteille commentedthank you for the quick reply! gotta try this! there is one thing though, I installed Shield and it looked like enabling / disabling it did rewrite .htaccess thus erased my custom modifications... I have to test it more thoroughly though.
Comment #52
nicolas bouteille commentedThank you your solution works perfect! and Shield module does not actually work with .htaccess so no pb.
Still curious to understand why this is only happening with OVH though and only since pretty recently as well...
Comment #53
nicolas bouteille commentedShame on me: I faced this problem again recently and totally forgot that I had already solved it earlier! And I did not find this issue when I googled it. Or maybe it is because I did not Google it but asked ChatGPT instead ^^
Hopefully OVH support did answer me and provided me with an article with the same solution.
https://habeuk.com/fr/drupal-neterrhttp2protocolerror