log4js-node / log4js-node/streamroller

Compress may cause Error: EPERM: operation not permitted open 'xxx\xxxx\xxxxx\myfile'. It`s ok with the option of compress is false.

Open
#175 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
38
Forks
20
PR merge metrics
No merged PRs in 30d

Description

This issue is discovered from "log4js-node", The latest version of "log4js-node" has the same issue because of this dependency.

replicate step:

  1. Download source code of this project.
  2. Create a 'index.js' file in root of this project.
  3. Input content in 'index.js' file:
var rollers = require('./lib/index');
var stream = new rollers.RollingFileStream('myfile', 10000, 12, {
  compress: true,
});

for (let i = 0; i < 30; i++) {
  // console.log(i);
  stream.write(getContent());
}

stream.end();

function getContent() {
  return `
  {
      a: {a: 1, b: 2, c: 3, d: 4, e: 5, f: 123321, g: 234432432, h: 31321, i: 23232, j: 23432423432432, k: 1123321},
      b: {a: 1, b: 2, c: 3, d: 4, e: 5, f: 123321, g: 234432432, h: 31321, i: 23232, j: 23432423432432, k: 1123321},
      c: {a: 1, b: 2, c: 3, d: 4, e: 5, f: 123321, g: 234432432, h: 31321, i: 23232, j: 23432423432432, k: 1123321},
     ......... // 70000 lines repeated
  }`
}
  1. Execute node index.js in terminal.
  2. Open the hot file "myfile" with notebook or VSCode as you like. This step is very important. The issue will not replicate without this step.
  3. Execute node index.js in terminal again. If no error occur, you can execute more times. The probability is very high, more than 50%.

Finally get this error in terminal:

Error: EPERM: operation not permitted, open 'D:\nodeProgram\TEST\test-streamroller\streamroller-master\myfile'
at Object.openSync (node:fs:596:3)
at Object.writeFileSync (node:fs:2322:35)
at Object.appendFileSync (node:fs:2384:6)
at RollingFileStream._renewWriteStream (D:\nodeProgram\TEST\test-streamroller\streamroller-master\lib\RollingFileWriteStream.js:312:8)
at RollingFileStream._moveOldFiles (D:\nodeProgram\TEST\test-streamroller\streamroller-master\lib\RollingFileWriteStream.js:232:10)
at async RollingFileStream._shouldRoll (D:\nodeProgram\TEST\test-streamroller\streamroller-master\lib\RollingFileWriteStream.js:170:7) {
errno: -4048,
syscall: 'open',
code: 'EPERM',
path: 'D:\nodeProgram\TEST\test-streamroller\streamroller-master\myfile'
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/RollingFileWriteStream.js, especially _shouldRoll, _moveOldFiles, and _renewWriteStream around the reported stack trace. Reproduce on Windows with the provided index.js, compress: true, and an open myfile; done means repeated runs no longer raise EPERM while rolling the file.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.