Skip to content

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Feb 1, 2026

Summary

Fixes flaky test test/parallel/test-repl-programmatic-history.js.

Problem

The test was flaky because the FileHandle for the history file could be garbage collected before being explicitly closed, causing ERR_INVALID_STATE errors when the handle was already closed by the GC finalizer.

Solution

  • Added an explicit closeHandle() method to ReplHistory class
  • Modified REPLServer.close() to wait for the history file handle to be properly closed before completing the close operation
  • This ensures deterministic cleanup regardless of GC timing

Verification

Verified with python3 tools/test.py --repeat 1000 test/parallel/test-repl-programmatic-history.js - all 1000 runs passed with 0 failures.

Refs: nodejs/reliability#1450

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Feb 1, 2026
The test was flaky because the FileHandle for the history file could
be garbage collected before being explicitly closed, causing
ERR_INVALID_STATE errors when the handle was already closed by the
GC finalizer.

This fix adds an explicit closeHandle() method to ReplHistory and
ensures that REPLServer.close() waits for the history file handle
to be properly closed before completing the close operation.

Refs: nodejs/reliability#1450
@mcollina mcollina force-pushed the fix-flaky-test-repl-programmatic-history branch from 56947c3 to e2afc62 Compare February 1, 2026 14:50
@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.76%. Comparing base (f6464c5) to head (e2afc62).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61614      +/-   ##
==========================================
- Coverage   89.76%   89.76%   -0.01%     
==========================================
  Files         673      673              
  Lines      203944   203969      +25     
  Branches    39191    39199       +8     
==========================================
+ Hits       183080   183102      +22     
  Misses      13194    13194              
- Partials     7670     7673       +3     
Files with missing lines Coverage Δ
lib/internal/repl/history.js 93.62% <100.00%> (+1.18%) ⬆️
lib/repl.js 94.15% <100.00%> (+0.03%) ⬆️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants