Skip to content

[bug] RangeError [ERR_FS_FILE_TOO_LARGE] when buffer set false. #103

@raoooool

Description

@raoooool

Describe the bug

Node.js version: v16.20.1

OS version: macOS 13.5.1

Description: the app crashes when attempting to read a file larger than 2GB.. setting config.buffer false.

Actual behavior

a file larger than 2GB located in the /public directory can cause the entire app to crash when attempting to read it.

Expected behavior

reading it normally.

Code to reproduce

const Koa = require("koa");
const path = require("path");
const staticCache = require("koa-static-cache");
const app = new Koa();

app.use(
  staticCache(path.join(__dirname, "public"), {
    buffer: false,
    dynamic: true,
    preload: false,
  })
);

app.use(async (ctx) => {
  ctx.body = "Hello World";
});

app.listen(3000);

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Other

I suspect the issue may be related to the loadFile function:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions