Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix exceptions occurring in 2.4.2 #38

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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