Skip to content

Commit 7157fc4

Browse files
author
Alexandre Perrin
committed
writeFileSync: close the fd on success.
This patch force the file descriptor open by writeFileSync to be closed on success (it was closed only on write error). Our Node.js application was throwing `EMFILE, too many open files' because file descriptors open by writeFileSync were never released. Sadly, this kind of bug is too much setup and platform dependent to be tested (we discovered it in production). Sponsored by: Net Oxygen (http://netoxygen.ch)
1 parent 3079c5a commit 7157fc4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: qr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268

269269
try {
270270
fs.writeSync(fd, buff, 0, buff.length, 0);
271-
} catch (error) {
271+
} finally {
272272
fs.closeSync(fd);
273273
}
274274
}

0 commit comments

Comments
 (0)