@@ -2475,17 +2475,19 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
24752475 }
24762476
24772477 FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2478- if (req_wrap_async != nullptr ) { // readBuffers(fd, buffers, pos, req)
2478+ if (argc > 3 ) { // readBuffers(fd, buffers, pos, req)
24792479 FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
24802480 AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
24812481 uv_fs_read, fd, *iovs, iovs.length (), pos);
24822482 } else { // readBuffers(fd, buffers, undefined, ctx)
2483- CHECK_EQ (argc, 5 );
2484- FSReqWrapSync req_wrap_sync;
2483+ FSReqWrapSync req_wrap_sync (" read" );
24852484 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);
24882487 FS_SYNC_TRACE_END (read, " bytesRead" , bytesRead);
2488+ if (is_uv_error (bytesRead)) {
2489+ return ;
2490+ }
24892491 args.GetReturnValue ().Set (bytesRead);
24902492 }
24912493}
0 commit comments