@@ -221,9 +221,15 @@ void FSReqPromise<AliasedBufferT>::Reject(v8::Local<v8::Value> reject) {
221
221
finished_ = true ;
222
222
v8::HandleScope scope (env ()->isolate ());
223
223
InternalCallbackScope callback_scope (this );
224
- v8::Local<v8::Value> value =
225
- object ()->Get (env ()->context (),
226
- env ()->promise_string ()).ToLocalChecked ();
224
+ v8::Local<v8::Value> value;
225
+ if (!object ()
226
+ ->Get (env ()->context (), env ()->promise_string ())
227
+ .ToLocal (&value)) {
228
+ // If we hit this, getting the value from the object failed and
229
+ // an error was likely scheduled. We could try to reject the promise
230
+ // but let's just allow the error to propagate.
231
+ return ;
232
+ }
227
233
v8::Local<v8::Promise::Resolver> resolver = value.As <v8::Promise::Resolver>();
228
234
USE (resolver->Reject (env ()->context (), reject).FromJust ());
229
235
}
@@ -233,9 +239,13 @@ void FSReqPromise<AliasedBufferT>::Resolve(v8::Local<v8::Value> value) {
233
239
finished_ = true ;
234
240
v8::HandleScope scope (env ()->isolate ());
235
241
InternalCallbackScope callback_scope (this );
236
- v8::Local<v8::Value> val =
237
- object ()->Get (env ()->context (),
238
- env ()->promise_string ()).ToLocalChecked ();
242
+ v8::Local<v8::Value> val;
243
+ if (!object ()->Get (env ()->context (), env ()->promise_string ()).ToLocal (&val)) {
244
+ // If we hit this, getting the value from the object failed and
245
+ // an error was likely scheduled. We could try to reject the promise
246
+ // but let's just allow the error to propagate.
247
+ return ;
248
+ }
239
249
v8::Local<v8::Promise::Resolver> resolver = val.As <v8::Promise::Resolver>();
240
250
USE (resolver->Resolve (env ()->context (), value).FromJust ());
241
251
}
@@ -255,9 +265,13 @@ void FSReqPromise<AliasedBufferT>::ResolveStatFs(const uv_statfs_t* stat) {
255
265
template <typename AliasedBufferT>
256
266
void FSReqPromise<AliasedBufferT>::SetReturnValue(
257
267
const v8::FunctionCallbackInfo<v8::Value>& args) {
258
- v8::Local<v8::Value> val =
259
- object ()->Get (env ()->context (),
260
- env ()->promise_string ()).ToLocalChecked ();
268
+ v8::Local<v8::Value> val;
269
+ if (!object ()->Get (env ()->context (), env ()->promise_string ()).ToLocal (&val)) {
270
+ // If we hit this, getting the value from the object failed and
271
+ // an error was likely scheduled. We could try to reject the promise
272
+ // but let's just allow the error to propagate.
273
+ return ;
274
+ }
261
275
v8::Local<v8::Promise::Resolver> resolver = val.As <v8::Promise::Resolver>();
262
276
args.GetReturnValue ().Set (resolver->GetPromise ());
263
277
}
0 commit comments