`fsPromise.writeFile` should catch stream's error and reject the promise.
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
Version
22.16.0
Platform
All
Subsystem
No response
What steps will reproduce the bug?
Following code fails with an application crash.
import fsp from "node:fs/promises";
import { createReadStream } from "node:fs";
try {
const s1 = createReadStream("not-existent");
await fsp.writeFile("new-file.txt", s1);
} catch (error) {
console.log(`Sorry file copy failed`);
}
Instead it should just say that an error has occurred and reject the promise.
How often does it reproduce? Is there a required condition?
Everytime
What is the expected behavior? Why is that the expected behavior?
The application should not crash and an error should be thrown.
What do you see instead?
Application Crashes.
Reproduction Repository
ackava/node-write-file-promise-fail
This repo contains docker container source code to reproduce error in container. On windows machine, delay causes app to crash but in container, slight delay of 1 ms causes crash.
Workaround
So far following code works correctly with slight time differences, and does not crash the app, promise is rejected correctly.
const writable = createWriteStream(outputFilePath);
return pipeline(inputStream, writable, { end: true });
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
再現例に示されている fsPromise.writeFile と createReadStream のエントリーポイントから始め、次にそれらのエラーハンドリングを pipeline の回避策と比較してください。リンクされた再現用リポジトリを使ってクラッシュを再現し、入力ファイルが存在しない場合にアプリケーションがクラッシュするのではなく promise が拒否されることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, nodejs
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100