@@ -2467,18 +2467,20 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
2467
2467
iovs[i] = uv_buf_init (Buffer::Data (buffer), Buffer::Length (buffer));
2468
2468
}
2469
2469
2470
- FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2471
- if ( req_wrap_async != nullptr ) { // readBuffers(fd, buffers, pos, req)
2470
+ if (argc > 3 ) { // readBuffers(fd, buffers, pos, req)
2471
+ FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2472
2472
FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
2473
2473
AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
2474
2474
uv_fs_read, fd, *iovs, iovs.length (), pos);
2475
2475
} else { // readBuffers(fd, buffers, undefined, ctx)
2476
- CHECK_EQ (argc, 5 );
2477
- FSReqWrapSync req_wrap_sync;
2476
+ FSReqWrapSync req_wrap_sync (" read" );
2478
2477
FS_SYNC_TRACE_BEGIN (read);
2479
- int bytesRead = SyncCall (env, /* ctx */ args[ 4 ], &req_wrap_sync, " read " ,
2480
- uv_fs_read, fd, *iovs, iovs.length (), pos);
2478
+ int bytesRead = SyncCallAndThrowOnError (
2479
+ env, &req_wrap_sync, uv_fs_read, fd, *iovs, iovs.length (), pos);
2481
2480
FS_SYNC_TRACE_END (read, " bytesRead" , bytesRead);
2481
+ if (is_uv_error (bytesRead)) {
2482
+ return ;
2483
+ }
2482
2484
args.GetReturnValue ().Set (bytesRead);
2483
2485
}
2484
2486
}
0 commit comments