| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 51ba566 commit b71250a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -460,7 +460,8 @@ MaybeLocal<Promise> FileHandle::ClosePromise() { | |||
| 460 | 460 | ||
| 461 | 461 | auto maybe_resolver = Promise::Resolver::New(context); | |
| 462 | 462 | CHECK(!maybe_resolver.IsEmpty()); | |
| 463 | - Local<Promise::Resolver> resolver = maybe_resolver.ToLocalChecked(); | ||
| 463 | + Local<Promise::Resolver> resolver; | ||
| 464 | + if (!maybe_resolver.ToLocal(&resolver)) return {}; | ||
| 464 | 465 | Local<Promise> promise = resolver.As<Promise>(); | |
| 465 | 466 | ||
| 466 | 467 | Local<Object> close_req_obj; | |
@@ -868,10 +869,12 @@ void AfterStringPath(uv_fs_t* req) { | |||
| 868 | 869 | req->path, | |
| 869 | 870 | req_wrap->encoding(), | |
| 870 | 871 | &error); | |
| 871 | - if (link.IsEmpty()) | ||
| 872 | + if (link.IsEmpty()) { | ||
| 872 | 873 | req_wrap->Reject(error); | |
| 873 | - else | ||
| 874 | - req_wrap->Resolve(link.ToLocalChecked()); | ||
| 874 | + } else { | ||
| 875 | + Local<Value> val; | ||
| 876 | + if (link.ToLocal(&val)) req_wrap->Resolve(val); | ||
| 877 | + } | ||
| 875 | 878 | } | |
| 876 | 879 | } | |
| 877 | 880 | ||
@@ -888,10 +891,12 @@ void AfterStringPtr(uv_fs_t* req) { | |||
| 888 | 891 | static_cast<const char*>(req->ptr), | |
| 889 | 892 | req_wrap->encoding(), | |
| 890 | 893 | &error); | |
| 891 | - if (link.IsEmpty()) | ||
| 894 | + if (link.IsEmpty()) { | ||
| 892 | 895 | req_wrap->Reject(error); | |
| 893 | - else | ||
| 894 | - req_wrap->Resolve(link.ToLocalChecked()); | ||
| 896 | + } else { | ||
| 897 | + Local<Value> val; | ||
| 898 | + if (link.ToLocal(&val)) req_wrap->Resolve(val); | ||
| 899 | + } | ||
| 895 | 900 | } | |
| 896 | 901 | } | |
| 897 | 902 | ||
@@ -2308,7 +2313,8 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) { | |||
| 2308 | 2313 | MaybeStackBuffer<uv_buf_t> iovs(chunks->Length()); | |
| 2309 | 2314 | ||
| 2310 | 2315 | for (uint32_t i = 0; i < iovs.length(); i++) { | |
| 2311 | - Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked(); | ||
| 2316 | + Local<Value> chunk; | ||
| 2317 | + if (!chunks->Get(env->context(), i).ToLocal(&chunk)) return; | ||
| 2312 | 2318 | CHECK(Buffer::HasInstance(chunk)); | |
| 2313 | 2319 | iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk)); | |
| 2314 | 2320 | } | |
@@ -2642,8 +2648,12 @@ static void ReadFileUtf8(const FunctionCallbackInfo<Value>& args) { | |||
| 2642 | 2648 | } | |
| 2643 | 2649 | FS_SYNC_TRACE_END(read); | |
| 2644 | 2650 | ||
| 2645 | - args.GetReturnValue().Set( | ||
| 2646 | - ToV8Value(env->context(), result, isolate).ToLocalChecked()); | ||
| 2651 | + Local<Value> val; | ||
| 2652 | + if (!ToV8Value(env->context(), result, isolate).ToLocal(&val)) { | ||
| 2653 | + return; | ||
| 2654 | + } | ||
| 2655 | + | ||
| 2656 | + args.GetReturnValue().Set(val); | ||
| 2647 | 2657 | } | |
| 2648 | 2658 | ||
| 2649 | 2659 | // Wrapper for readv(2). | |
@@ -2671,7 +2681,8 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) { | |||
| 2671 | 2681 | ||
| 2672 | 2682 | // Init uv buffers from ArrayBufferViews | |
| 2673 | 2683 | for (uint32_t i = 0; i < iovs.length(); i++) { | |
| 2674 | - Local<Value> buffer = buffers->Get(env->context(), i).ToLocalChecked(); | ||
| 2684 | + Local<Value> buffer; | ||
| 2685 | + if (!buffers->Get(env->context(), i).ToLocal(&buffer)) return; | ||
| 2675 | 2686 | CHECK(Buffer::HasInstance(buffer)); | |
| 2676 | 2687 | iovs[i] = uv_buf_init(Buffer::Data(buffer), Buffer::Length(buffer)); | |
| 2677 | 2688 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments