@@ -2238,18 +2238,29 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
2238
2238
iovs[i] = uv_buf_init (Buffer::Data (chunk), Buffer::Length (chunk));
2239
2239
}
2240
2240
2241
- FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2242
- if ( req_wrap_async != nullptr ) { // writeBuffers(fd, chunks, pos, req)
2241
+ if (argc > 3 ) { // writeBuffers(fd, chunks, pos, req)
2242
+ FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2243
2243
FS_ASYNC_TRACE_BEGIN0 (UV_FS_WRITE, req_wrap_async)
2244
- AsyncCall (env, req_wrap_async, args, " write" , UTF8, AfterInteger,
2245
- uv_fs_write, fd, *iovs, iovs.length (), pos);
2246
- } else { // writeBuffers(fd, chunks, pos, undefined, ctx)
2247
- CHECK_EQ (argc, 5 );
2248
- FSReqWrapSync req_wrap_sync;
2244
+ AsyncCall (env,
2245
+ req_wrap_async,
2246
+ args,
2247
+ " write" ,
2248
+ UTF8,
2249
+ AfterInteger,
2250
+ uv_fs_write,
2251
+ fd,
2252
+ *iovs,
2253
+ iovs.length (),
2254
+ pos);
2255
+ } else { // writeBuffers(fd, chunks, pos)
2256
+ FSReqWrapSync req_wrap_sync (" write" );
2249
2257
FS_SYNC_TRACE_BEGIN (write);
2250
- int bytesWritten = SyncCall (env, args[ 4 ], &req_wrap_sync, " write " ,
2251
- uv_fs_write, fd, *iovs, iovs.length (), pos);
2258
+ int bytesWritten = SyncCallAndThrowOnError (
2259
+ env, &req_wrap_sync, uv_fs_write, fd, *iovs, iovs.length (), pos);
2252
2260
FS_SYNC_TRACE_END (write, " bytesWritten" , bytesWritten);
2261
+ if (is_uv_error (bytesWritten)) {
2262
+ return ;
2263
+ }
2253
2264
args.GetReturnValue ().Set (bytesWritten);
2254
2265
}
2255
2266
}
0 commit comments