Skip to content

Commit

Permalink
fix: reject promise on file stream error when writing heap snapshot (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Mar 28, 2024
1 parent d8f6199 commit 20bc193
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/beacon-node/src/util/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export async function writeHeapSnapshot(prefix: string, dirpath: string): Promis
const snapshotStream = v8.getHeapSnapshot();
const filepath = `${dirpath}/${prefix}_${new Date().toISOString()}.heapsnapshot`;
const fileStream = fs.createWriteStream(filepath);
return new Promise<string>((resolve) => {
return new Promise<string>((resolve, reject) => {
fileStream.on("error", (err) => {
reject(err);
});

snapshotStream.pipe(fileStream);
snapshotStream.on("end", () => {
resolve(filepath);
Expand Down

0 comments on commit 20bc193

Please sign in to comment.