Skip to content

Commit 9d08876

Browse files
committed
repl: fix FileHandle leak in history initialization
Ensure that the history file handle is closed if initialization fails or flushing throws an error. This prevents ERR_INVALID_STATE errors where a FileHandle object is closed during garbage collection.
1 parent 413dffc commit 9d08876

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/internal/repl/history.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ class ReplHistory {
327327

328328
await this[kFlushHistory]();
329329
} catch (err) {
330+
await this[kCloseHandle]();
330331
return this[kHandleHistoryInitError](err, onReadyCallback);
331332
}
332333
}

0 commit comments

Comments
 (0)