@@ -2467,18 +2467,20 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
24672467 iovs[i] = uv_buf_init (Buffer::Data (buffer), Buffer::Length (buffer));
24682468 }
24692469
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 );
24722472 FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
24732473 AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
24742474 uv_fs_read, fd, *iovs, iovs.length (), pos);
24752475 } else { // readBuffers(fd, buffers, undefined, ctx)
2476- CHECK_EQ (argc, 5 );
2477- FSReqWrapSync req_wrap_sync;
2476+ FSReqWrapSync req_wrap_sync (" read" );
24782477 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);
24812480 FS_SYNC_TRACE_END (read, " bytesRead" , bytesRead);
2481+ if (is_uv_error (bytesRead)) {
2482+ return ;
2483+ }
24822484 args.GetReturnValue ().Set (bytesRead);
24832485 }
24842486}
0 commit comments