(file: NodeJS.WritableStream)
| 135 | } |
| 136 | |
| 137 | function closeFile(file: NodeJS.WritableStream): Promise<void> { |
| 138 | return new Promise<void>((resolve) => { |
| 139 | // Best-effort cleanup: any underlying failure has already been |
| 140 | // surfaced as the original throw from the for-await loop. We |
| 141 | // listen for `error` so a failing close (bad fd, late ENOSPC on |
| 142 | // flush) doesn't leak an unhandled 'error' onto the stream, and |
| 143 | // resolve either way so the finally block proceeds to unlinkSync. |
| 144 | const done = (): void => { |
| 145 | file.off("error", done); |
| 146 | resolve(); |
| 147 | }; |
| 148 | file.once("error", done); |
| 149 | file.end(() => done()); |
| 150 | }); |
| 151 | } |
no test coverage detected