@@ -375,11 +375,10 @@ inline FSReqWrap* AsyncCall(Environment* env,
375375// the error number and the syscall in the context instead of
376376// creating an error in the C++ land.
377377template <typename Func, typename ... Args>
378- inline void SyncCall (Environment* env, Local<Value> ctx,
378+ inline int SyncCall (Environment* env, Local<Value> ctx, fs_req_wrap* req_wrap ,
379379 const char * syscall, Func fn, Args... args) {
380- fs_req_wrap req_wrap;
381380 env->PrintSyncTrace ();
382- int err = fn (env->event_loop (), &req_wrap. req , args..., nullptr );
381+ int err = fn (env->event_loop (), &( req_wrap-> req ) , args..., nullptr );
383382 if (err < 0 ) {
384383 Local<Context> context = env->context ();
385384 Local<Object> ctx_obj = ctx->ToObject (context).ToLocalChecked ();
@@ -391,6 +390,7 @@ inline void SyncCall(Environment* env, Local<Value> ctx,
391390 env->syscall_string (),
392391 OneByteString (isolate, syscall)).FromJust ();
393392 }
393+ return err;
394394}
395395
396396#define SYNC_DEST_CALL (func, path, dest, ...) \
@@ -426,7 +426,8 @@ void Access(const FunctionCallbackInfo<Value>& args) {
426426 AsyncCall (env, args, " access" , UTF8, AfterNoArgs,
427427 uv_fs_access, *path, mode);
428428 } else { // access(path, mode, undefined, ctx)
429- SyncCall (env, args[3 ], " access" , uv_fs_access, *path, mode);
429+ fs_req_wrap req_wrap;
430+ SyncCall (env, args[3 ], &req_wrap, " access" , uv_fs_access, *path, mode);
430431 }
431432}
432433
@@ -446,7 +447,8 @@ void Close(const FunctionCallbackInfo<Value>& args) {
446447 AsyncCall (env, args, " close" , UTF8, AfterNoArgs,
447448 uv_fs_close, fd);
448449 } else { // close(fd, undefined, ctx)
449- SyncCall (env, args[2 ], " close" , uv_fs_close, fd);
450+ fs_req_wrap req_wrap;
451+ SyncCall (env, args[2 ], &req_wrap, " close" , uv_fs_close, fd);
450452 }
451453}
452454
0 commit comments