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.

オープン
#175 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
38
フォーク
20
PR マージ指標
30日以内にマージされた PR はありません

説明

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
}`
}
```
4. Execute `node index.js` in terminal.
5. 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.
6. 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'
}

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

報告された stack trace を手がかりに、lib/RollingFileWriteStream.js の _shouldRoll、_moveOldFiles、_renewWriteStream を中心に調査を始めてください。提供された index.js、compress: true、開いた状態の myfile を使って Windows で再現します。ファイルのローテーション中に繰り返し実行しても EPERM が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。