@@ -287,21 +287,27 @@ FSReqBase* GetReqWrap(const v8::FunctionCallbackInfo<v8::Value>& args,
287
287
int index,
288
288
bool use_bigint) {
289
289
v8::Local<v8::Value> value = args[index];
290
+ FSReqBase* result = nullptr ;
290
291
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
+ }
302
305
}
303
306
}
304
- return nullptr ;
307
+ if (result != nullptr ) {
308
+ result->SetReturnValue (args);
309
+ }
310
+ return result;
305
311
}
306
312
307
313
// Returns nullptr if the operation fails from the start.
@@ -320,10 +326,7 @@ FSReqBase* AsyncDestCall(Environment* env, FSReqBase* req_wrap,
320
326
uv_req->path = nullptr ;
321
327
after (uv_req); // after may delete req_wrap if there is an error
322
328
req_wrap = nullptr ;
323
- } else {
324
- req_wrap->SetReturnValue (args);
325
329
}
326
-
327
330
return req_wrap;
328
331
}
329
332
0 commit comments