@@ -2564,18 +2564,20 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
25642564 iovs[i] = uv_buf_init (Buffer::Data (buffer), Buffer::Length (buffer));
25652565 }
25662566
2567- FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2568- if ( req_wrap_async != nullptr ) { // readBuffers(fd, buffers, pos, req)
2567+ if (argc > 3 ) { // readBuffers(fd, buffers, pos, req)
2568+ FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
25692569 FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
25702570 AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
25712571 uv_fs_read, fd, *iovs, iovs.length (), pos);
25722572 } else { // readBuffers(fd, buffers, undefined, ctx)
2573- CHECK_EQ (argc, 5 );
2574- FSReqWrapSync req_wrap_sync;
2573+ FSReqWrapSync req_wrap_sync (" read" );
25752574 FS_SYNC_TRACE_BEGIN (read);
2576- int bytesRead = SyncCall (env, /* ctx */ args[ 4 ], &req_wrap_sync, " read " ,
2577- uv_fs_read, fd, *iovs, iovs.length (), pos);
2575+ int bytesRead = SyncCallAndThrowOnError (
2576+ env, &req_wrap_sync, uv_fs_read, fd, *iovs, iovs.length (), pos);
25782577 FS_SYNC_TRACE_END (read, " bytesRead" , bytesRead);
2578+ if (is_uv_error (bytesRead)) {
2579+ return ;
2580+ }
25792581 args.GetReturnValue ().Set (bytesRead);
25802582 }
25812583}
0 commit comments