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.

Aperta
#175 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
38
Fork
20
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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'
}

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in lib/RollingFileWriteStream.js, soprattutto in _shouldRoll, _moveOldFiles e _renewWriteStream, partendo dallo stack trace segnalato. Riproduci il problema su Windows con l'index.js fornito, compress: true e un myfile aperto; il lavoro è completato quando le esecuzioni ripetute non generano più EPERM durante la rotazione del file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.