@@ -2205,18 +2205,20 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
2205
2205
iovs[i] = uv_buf_init (Buffer::Data (chunk), Buffer::Length (chunk));
2206
2206
}
2207
2207
2208
- FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2209
- if (req_wrap_async != nullptr ) { // writeBuffers(fd, chunks, pos, req)
2210
- FS_ASYNC_TRACE_BEGIN0 (UV_FS_WRITE, req_wrap_async)
2211
- AsyncCall (env, req_wrap_async, args, " write" , UTF8, AfterInteger,
2208
+ if (argc > 3 ) { // writeBuffers(fd, chunks, pos, req)
2209
+ FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2210
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_WRITE, req_wrap_async)
2211
+ AsyncCall (env, req_wrap_async, args, " write" , UTF8, AfterInteger,
2212
2212
uv_fs_write, fd, *iovs, iovs.length (), pos);
2213
- } else { // writeBuffers(fd, chunks, pos, undefined, ctx)
2214
- CHECK_EQ (argc, 5 );
2215
- FSReqWrapSync req_wrap_sync;
2213
+ } else { // writeBuffers(fd, chunks, pos)
2214
+ FSReqWrapSync req_wrap_sync (" write" );
2216
2215
FS_SYNC_TRACE_BEGIN (write);
2217
- int bytesWritten = SyncCall (env, args[ 4 ], &req_wrap_sync, " write " ,
2216
+ int bytesWritten = SyncCallAndThrowOnError (env, &req_wrap_sync,
2218
2217
uv_fs_write, fd, *iovs, iovs.length (), pos);
2219
2218
FS_SYNC_TRACE_END (write, " bytesWritten" , bytesWritten);
2219
+ if (is_uv_error (bytesWritten)) {
2220
+ return ;
2221
+ }
2220
2222
args.GetReturnValue ().Set (bytesWritten);
2221
2223
}
2222
2224
}
0 commit comments