Fix file descriptor leak in utimesMillisSync#1066
Conversation
Agent-Logs-Url: https://github.com/jprichardson/node-fs-extra/sessions/b96a4f0a-2672-406f-9c6a-bd78c8a7ab99 Co-authored-by: RyanZim <17342435+RyanZim@users.noreply.github.com>
|
After this is merged, should take care of #1065 (comment) |
Agent-Logs-Url: https://github.com/jprichardson/node-fs-extra/sessions/685e7e26-4679-4fd1-bec5-820f5e2780e0 Co-authored-by: JPeer264 <10677263+JPeer264@users.noreply.github.com>
Added a test in commit |
JPeer264
left a comment
There was a problem hiding this comment.
Not sure if the test is actually correct - as it only checks if closeSync is called, would be nice if someone could verify that.
The changes actually look good (except this one: #1065 (comment))
|
@JPeer264 Copilot's new test is a mirror of our existing test for node-fs-extra/lib/util/__tests__/utimes.test.js Lines 70 to 98 in a4000d6 This seems correct; as long as close is called in the error case, it shouldn't leak. Is there something I'm missing? |
|
Merged to move on to #1066 (comment); if there's a problem with the test, we can fix in a follow-up PR. |
utimesMillisSyncdid not wrapfutimesSyncin a try/finally block, so a thrown error would cause the opened file descriptor to never be closed.utimesMillis(the async counterpart) already handled this correctly.Changes
lib/util/utimes.js: RewroteutimesMillisSyncto mirror the try/catch/finally pattern fromutimesMillis—closeSyncis now always called in thefinallyblock regardless of whetherfutimesSyncthrows.lib/util/__tests__/utimes.test.js: Added a test forutimesMillisSyncthat verifiescloseSyncis called even whenfutimesSyncthrows, confirming no file descriptor leak occurs.