Commit 60478b6
committed
fix(storage): handle upload errors before pipeline setup
createWriteStream starts the simple or resumable upload before installing the pipeline that normally owns fileWriteStream errors. If startup fails synchronously, fileWriteStream and the public write stream are destroyed before pipeline() runs. Node 24 and newer then throw ERR_STREAM_UNABLE_TO_PIPE while attaching the already-invalid streams, and the original upload error can escape uncaught.
Install a temporary error listener before upload startup and forward any early failure through the existing pipeline callback. If startup destroyed the source, destination, or public stream, tear down the remaining stream and skip pipeline setup. Remove the temporary listener once the normal pipeline is ready to take ownership.
This restores the existing createWriteStream error tests on Node 24 and 26 without changing successful upload behavior.1 parent b97be01 commit 60478b6
1 file changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2192 | 2192 | | |
2193 | 2193 | | |
2194 | 2194 | | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
2195 | 2200 | | |
2196 | 2201 | | |
2197 | 2202 | | |
2198 | 2203 | | |
2199 | 2204 | | |
2200 | 2205 | | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
2201 | 2217 | | |
2202 | 2218 | | |
2203 | 2219 | | |
| |||
0 commit comments