@@ -2483,18 +2483,20 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
2483
2483
iovs[i] = uv_buf_init (Buffer::Data (buffer), Buffer::Length (buffer));
2484
2484
}
2485
2485
2486
- FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2487
- if ( req_wrap_async != nullptr ) { // readBuffers(fd, buffers, pos, req)
2486
+ if (argc > 3 ) { // readBuffers(fd, buffers, pos, req)
2487
+ FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2488
2488
FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
2489
2489
AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
2490
2490
uv_fs_read, fd, *iovs, iovs.length (), pos);
2491
2491
} else { // readBuffers(fd, buffers, undefined, ctx)
2492
- CHECK_EQ (argc, 5 );
2493
- FSReqWrapSync req_wrap_sync;
2492
+ FSReqWrapSync req_wrap_sync (" read" );
2494
2493
FS_SYNC_TRACE_BEGIN (read);
2495
- int bytesRead = SyncCall (env, /* ctx */ args[ 4 ], &req_wrap_sync, " read " ,
2496
- uv_fs_read, fd, *iovs, iovs.length (), pos);
2494
+ int bytesRead = SyncCallAndThrowOnError (
2495
+ env, &req_wrap_sync, uv_fs_read, fd, *iovs, iovs.length (), pos);
2497
2496
FS_SYNC_TRACE_END (read, " bytesRead" , bytesRead);
2497
+ if (is_uv_error (bytesRead)) {
2498
+ return ;
2499
+ }
2498
2500
args.GetReturnValue ().Set (bytesRead);
2499
2501
}
2500
2502
}
0 commit comments