Skip to content

Commit

Permalink
Ignore errors raised by fs.closeSync()
Browse files Browse the repository at this point in the history
As per comments here:
3365a4d

Close #38
  • Loading branch information
lukeapage authored and isaacs committed May 24, 2019
1 parent e5c9adb commit f8b1552
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ function writeFileSync (filename, data, options) {
fs.renameSync(tmpfile, filename)
removeOnExitHandler()
} catch (err) {
if (fd) fs.closeSync(fd)
if (fd) {
try {
fs.closeSync(fd)
} catch (ex) {
// ignore close errors at this stage, error may have closed fd already.
}
}
removeOnExitHandler()
cleanup()
throw err
Expand Down

0 comments on commit f8b1552

Please # to comment.