mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
destroy() fsynced and closed the fd right away, even while an fs.write() on it was still running on the thread pool. The write then failed with EBADF, emitted as an 'error' that crashed the process when nothing listened for it, or landed in whatever file reused the fd number. Close the fd once the in-flight write completes, as fs.WriteStream does. Data buffered behind it is still dropped, so 'finish' is not emitted in that case. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com> PR-URL: https://github.com/nodejs/node/pull/67355 Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-11-09.md Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>