Frequent ERR_CONTENT_LENGTH_MISMATCH errors in browser console in dev environment

AI-generated summary

This thread discusses frequent ERR_CONTENT_LENGTH_MISMATCH and ERR_INCOMPLETE_CHUNKED_ENCODING errors occurring in a Discourse development environment. NateDhaliwal reports that these console errors cause pages to fail loading initially, requiring multiple reloads or server restarts to resolve. The issue is particularly disruptive when using the discourse_theme gem, as automatic tab reloads can result in permanent loading states. The user notes the environment runs on WSL2 (Ubuntu) within VS Code Dev Containers.

After following up on the persistence of the issue, david suggests the problem may be related to a known VS Code remote extension bug (vscode-remote-release#9969). David points out that a fix was recently merged into the main VS Code repository (microsoft/vscode#338875) and should be available in the ‘insiders’ build.

I get these errors on my dev environment frequently:

discourse-reactions_main.Q5vqJe-h8ro1ilp.digested.js:1  Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
chunk-jiiahumh.digested.js:1  Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
chunk-mkia0op3.digested.js:1  Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

Or:

GET http://localhost:3000/assets/js/plugins/chat_main.DXNPoW-htkfwtbk.digested.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
(index):90  GET http://localhost:3000/assets/js/plugins/discourse-ai_admin.DncC-f-mtqe97w7.digested.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
(index):541  GET http://localhost:3000/stylesheets/admin_c962958770e1245d5bb1026e1e40f1ef3ef611f6.css?__ws=localhost net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
(index):545  GET http://localhost:3000/stylesheets/chat_c962958770e1245d5bb1026e1e40f1ef3ef611f6.css?__ws=localhost net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
color_definitions_dark_13_-1_2507ff89a2ca761acdb701533aca3014e900a7a0.css?__ws=localhost:1  GET http://localhost:3000/fonts/InterVariable.woff2?v=0.0.19 net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
(index):126  GET http://localhost:3000/assets/js/plugins/discourse-reactions_main.Q5vqJe-h8ro1ilp.digested.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

No idea why. The page doesn’t load half the time too. It takes around 2-3 reloads and some luck to get it to load. Very frustrating when paired with the discourse_theme gem since updates do a reload of the tab, potentially causing a forever load.

When the page does load, however, these errors don’t appear initially, but they do after the usual log:

This seems related too:

Like the linked topic, my environment is on WSL2 (Ubuntu) using Dev Containers.

1 Like

Any updates on this? I’m still getting this on my dev environment when I boot it up. Page just shows the Discourse loading indicator with no change; browser console says this:

Throwing in a cocktail of soft and hard reloads but to no avail :frowning: … only after some more reloads and restarts of the dev server does it load.

I found this, which includes some responses referencing Discourse:

Seems like it might’ve been fixed via Prevent truncated responses through managed port-forwarding sockets - Pull Request #338875 - microsoft/vscode - GitHub, which was merged a few days ago. Should be live in the ‘insiders’ build of VSCode already :crossed_fingers:

2 Likes