Skip to content

Commit

Permalink
fix: Fix test that causes a GC warning
Browse files Browse the repository at this point in the history
One of the tests mocks the open FileHandle in order to
test an error condition. The Garbage Collector was showing
a warning from not closing the original FileHandle. This
corrects that and closes the real FH before mocking.

Semver: patch
  • Loading branch information
darinspivey committed Jun 8, 2021
1 parent b87ff67 commit 165c5c9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/tail-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ test('Success: Filehandle close NOOPs on error', async (t) => {
// Force an error for FH close. NOTE: this mock is only needed for node 14
// which does NOT throw an error as in 10 and 12. Keeps converage at 100% for
// the matrix.

const realFH = tail[symbols.fileHandle]
await realFH.close() // Prevent GC error from not closing this for real

tail[symbols.fileHandle] = {
close: async () => {
throw new Error('NOPE')
Expand Down

0 comments on commit 165c5c9

Please sign in to comment.