ECONNRESET and ECONNABORT errors when serving mp4 from public folder

System Information
  • 4/latest:
  • Windows 10:
  • MySQL:
  • 14.16.0:
  • 6.14.11:
  • using just npm:

Bug report

ECONNRESET and ECONNABORT error messages in strapi console

When I spam click F5 in the browser, I get ECONNRESET and ECONNABORT error messages in the strapi console.

Steps to reproduce the behavior

  1. Create a new strapi project version 3.6.8 or 4/latest
  2. Start strapi server
  3. Log in
  4. Go to Media Library
  5. upload a mp4 file
  6. create a simple html file containing a <video src="localhost:1337/uploads/upload_someHash.mp4 controls /> in the body
  7. open the html
  8. video should load an work normally
  9. you should see a 206 get request in the browser network tab and in strapi console
  10. start spam clicking F5
  11. you should encounter above mentioned errors after a while in the strapi console

Expected behavior

To not see these errors in the strapi console, because the connection reset or abortion should get handled somewhere.


Code snippets

I can catch the error in node-modules/koa/lib/context.js in the onerror(err) function:

onerror(err) {
    // don't do anything if there is no error.
    // this allows you to pass `this.onerror`
    // to node-style callbacks.
    if (null == err) return;

    // When dealing with cross-globals a normal `instanceof` check doesn't work properly.
    // See
    // We can probably remove it once jest fixes
    const isNativeError = === '[object Error]' ||
      err instanceof Error;
    if (!isNativeError) err = new Error(util.format('non-error thrown: %j', err));

    let headerSent = false;
    if (this.headerSent || !this.writable) {
      headerSent = err.headerSent = true;


    // delegate'error', err, this);

I can see the koa-range package beeing involved creating the 206 partial-content response.
In node-modules/koa-range/index.js line 70:

ctx.set('Content-Range', rangeContentGenerator(start, end, len));
ctx.status = 206;

I can catch the error and override it with my own console log in node-modules/strapi/lib/Strapi.js. But I don’t like having to override node-module.

class Strapi {
  constructor(opts = {}) {
    this.reload = this.reload();

    // Expose `koa`. = new Koa();

    this.router = new Router();


    // Logger.
    this.log = logger;"error", (error) => {
    if (error.code === "ECONNABORTED" || error.code === "ECONNRESET") {
      this.log.debug("video stream was aborted by client", { error });
    } else {
      this.log.error("Koa app-level error", { error });

I can also see the error in ./config/bootstrap.js. But this does not override the logger, I then get 2 messages in the console:

module.exports = async () => {
  console.log("bootstrap.js");"error", (error) => {
    if (error.code === "ECONNABORTED" || error.code === "ECONNRESET") {
      strapi.log.debug("video stream was aborted by client", { error });
    } else {
      strapi.log.error("Koa app-level error", { error });

Additional context

A simple koa setup serves the mp4 with request 200 - no problems there
I have yet to build a simple koa setup using koa-range and serve the files with 206. Would be interesting to see what happens.
Opend a thread in github issues:

My question is: Is it ok to just ignore these error messages? Nothing breaks or crashes, the videos play just fine. And if yes where would be the best place to catch them?