rotating-file-stream: [bug] Cannot read properties of undefined (reading 'write')

I got this error

/app/packages/shared/node_modules/rotating-file-stream/dist/cjs/index.js:89
                await this.file.write(chunk);
                                ^
TypeError: Cannot read properties of undefined (reading 'write')
    at RotatingFileStream.rewrite (/app/packages/shared/node_modules/rotating-file-stream/dist/cjs/index.js:89:33)

Running the application in a docker container, everything was running fine for around a week then this error caused the app to crash.

Any clue what could be the reason?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 25 (12 by maintainers)

Most upvoted comments

I still have this problem with v3.1.1. I’m using Typescript with these options in tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "CommonJS",
    "esModuleInterop": true
  }
}

My server.ts:

import rfs from "rotating-file-stream";
const accessLogStream = rfs.createStream("access.log", {
  interval: "1d"
});

When I use require instead of import then it works fine: const rfs = require("rotating-file-stream"); Am I doing anything wrong here?

EDIT: Nevermind, this works fine: import * as rfs from "rotating-file-stream";

Ciao Daniele,

thanks for looking at this, unfortunately the issue happens occasionally and I have no way to reproduce it, If I get a change to send you some useful logs I will do.