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