-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: fix not found
close
creation context
- Loading branch information
Showing
2 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
// This test runs `fs.readFile` which calls ReadFileContext | ||
// that triggers binding.close() when read operation is done. | ||
// The goal of this test is to not crash | ||
let val; | ||
|
||
// For loop is required to trigger fast API. | ||
for (let i = 0; i < 100_000; i++) { | ||
try { | ||
val = fs.readFile(__filename, (a, b) => { | ||
try { | ||
assert.strictEqual(a, null); | ||
assert.ok(b.length > 0); | ||
} catch { | ||
// Ignore all errors | ||
} | ||
}); | ||
} catch { | ||
// do nothing | ||
} | ||
} | ||
|
||
console.log(val); |