@@ -287,21 +287,27 @@ FSReqBase* GetReqWrap(const v8::FunctionCallbackInfo<v8::Value>& args,
287287                      int  index,
288288                      bool  use_bigint) {
289289  v8::Local<v8::Value> value = args[index];
290+   FSReqBase* result = nullptr ;
290291  if  (value->IsObject ()) {
291-     return  BaseObject::Unwrap<FSReqBase>(value.As <v8::Object>());
292-   }
293- 
294-   Realm* realm = Realm::GetCurrent (args);
295-   BindingData* binding_data = realm->GetBindingData <BindingData>();
296- 
297-   if  (value->StrictEquals (realm->isolate_data ()->fs_use_promises_symbol ())) {
298-     if  (use_bigint) {
299-       return  FSReqPromise<AliasedBigInt64Array>::New (binding_data, use_bigint);
300-     } else  {
301-       return  FSReqPromise<AliasedFloat64Array>::New (binding_data, use_bigint);
292+     result = BaseObject::Unwrap<FSReqBase>(value.As <v8::Object>());
293+   } else  {
294+     Realm* realm = Realm::GetCurrent (args);
295+     BindingData* binding_data = realm->GetBindingData <BindingData>();
296+ 
297+     if  (value->StrictEquals (realm->isolate_data ()->fs_use_promises_symbol ())) {
298+       if  (use_bigint) {
299+         result =
300+             FSReqPromise<AliasedBigInt64Array>::New (binding_data, use_bigint);
301+       } else  {
302+         result =
303+             FSReqPromise<AliasedFloat64Array>::New (binding_data, use_bigint);
304+       }
302305    }
303306  }
304-   return  nullptr ;
307+   if  (result != nullptr ) {
308+     result->SetReturnValue (args);
309+   }
310+   return  result;
305311}
306312
307313//  Returns nullptr if the operation fails from the start.
@@ -320,10 +326,7 @@ FSReqBase* AsyncDestCall(Environment* env, FSReqBase* req_wrap,
320326    uv_req->path  = nullptr ;
321327    after (uv_req);  //  after may delete req_wrap if there is an error
322328    req_wrap = nullptr ;
323-   } else  {
324-     req_wrap->SetReturnValue (args);
325329  }
326- 
327330  return  req_wrap;
328331}
329332
0 commit comments