Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some (but not all) static files fail to be served - ERR_CONTENT_LENGTH_MISMATCH

See original GitHub issue



  • Deno Version: 1.17 (updated today)
  • v8 Version: Not sure, the one shipped with Deno 1.17?
  • Typescript Version: 4.5
  • Opine Version: 2.0.0


I am using Opine to serve my Angular application’s static files. Angular’s “dist” folder contains :

- index.html (2.2 KB)
- main.js (182 KB, development version, un-minified)
- polyfill.js (44 KB)
- runtime.js (1 KB) 
- styles.css (7.7 KB)

My server code :

import { opine, serveStatic } from "";
import { distDir } from "./utils.ts"

console.log(`distDir = `, distDir); // Logs "distDir =  D:\dev\Dwiki\front\dist", that's correct

const app = opine();


app.get("/", (req, res) => res.sendFile(distDir + "/index.html"))

await app.listen(8090);

console.log(`App listening on http://localhost:8090`);

Result :

When I localhost:8090, some files get loaded, some don’t :

- index.html (2.2 KB) --> OK 200
- main.js (182 KB) --> (failed)net::ERR_CONTENT_LENGTH_MISMATCH
- polyfill.js (44 KB)--> (failed)net::ERR_CONTENT_LENGTH_MISMATCH
- runtime.js (1 KB) --> OK 200
- styles.css ( 7.7 KB) --> OK 200

No error in the terminal or in the browser’s console. All that’s displayed in my terminal is :

distDir = D:\dev\Dwiki\front\dist App listening on http://localhost:8090

If I serve my Angular app with ng serve, it displays correctly.

I can see the content of index.html, runtime.js and styles.css in the browser’s network tab. Not sure why some files are served correctly by Deno/Opine, and some (always these two) get (failed)net::ERR_CONTENT_LENGTH_MISMATCH


I noticed the two files that fail to be served are also the two heaviest of the lot. I have updated my question, adding the weight of each file, above. It looks like small files (7 KB, 1 KB, 2 KB) are being served normally, but heavier files (44 KB, 182 KB) get ERR_CONTENT_LENGTH_MISMATCH

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

xyzshantaramcommented, Dec 31, 2021

@cmorten – Here you go!

Sorry I couldn’t work on it last year 😉

jeremythillecommented, Jan 13, 2022

For the record, I still haven’t tried @cmorten’s fix, because I’m still trying to code a little server using native Deno code (for learning purposes, I want to understand how Deno works before using libraries), and I have the same issue without Opine.

For that matter, I have just opened a similar issue on Deno’s repo:

So… is it an Opine, or a Deno issue after all? 😃


It is a “me” issue! I forgot to encapsulate the inner await in an anonymous function, it works now. Sorry folks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

They include static files (jquery, bootstrap etc.) and when I refresh the browser a few times I always get the content length mismatch...
Read more >
Flask static files error: Failed to load resource: net
It loads the main/home blueprint and serves the correct template. What it does not do is serve any css or js resources in...
Read more >
How to manage static files (e.g. images, JavaScript, CSS)
This page describes how you can serve these static files. ... If you don't have django.contrib.staticfiles in INSTALLED_APPS , you can still manually...
Read more >
Storing and serving static files - App Engine - Google Cloud
Requests to static files or static directories are handled by the App Engine infrastructure directly, and do not reach the language runtime of...
Read more >
Working with Static and Media Files in Django |
This article looks at how to work with static and media files in a Django project, locally and in production.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found