GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: replace ToLocalChecked uses with ToLocal in node-file by jasnell · Pull Request #53869 · nodejs/node

src: replace ToLocalChecked uses with ToLocal in node-file #53869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jasnell wants to merge 1 commit into nodejs:main from jasnell:replace-node-file-tolocalchecks

Uh oh!

There was an error while loading. Please reload this page.

Closed

src: replace ToLocalChecked uses with ToLocal in node-file #53869

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
b85c0e5
src: replace ToLocalChecked uses with ToLocal in node-file
jasnell Jul 16, 2024
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

32 changes: 23 additions & 9 deletions 32 src/node_file-inl.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,15 @@ void FSReqPromise<AliasedBufferT>::Reject(v8::Local<v8::Value> reject) {
finished_ = true;
v8::HandleScope scope(env()->isolate());
InternalCallbackScope callback_scope(this);
v8::Local<v8::Value> value =
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
v8::Local<v8::Value> value;
if (!object()
->Get(env()->context(), env()->promise_string())
.ToLocal(&value)) {
// If we hit this, getting the value from the object failed and
// an error was likely scheduled. We could try to reject the promise
// but let's just allow the error to propagate.
return;
}
v8::Local<v8::Promise::Resolver> resolver = value.As<v8::Promise::Resolver>();
USE(resolver->Reject(env()->context(), reject).FromJust());
}
Expand All @@ -233,9 +239,13 @@ void FSReqPromise<AliasedBufferT>::Resolve(v8::Local<v8::Value> value) {
finished_ = true;
v8::HandleScope scope(env()->isolate());
InternalCallbackScope callback_scope(this);
v8::Local<v8::Value> val =
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
v8::Local<v8::Value> val;
if (!object()->Get(env()->context(), env()->promise_string()).ToLocal(&val)) {
// If we hit this, getting the value from the object failed and
// an error was likely scheduled. We could try to reject the promise
// but let's just allow the error to propagate.
return;
}
v8::Local<v8::Promise::Resolver> resolver = val.As<v8::Promise::Resolver>();
USE(resolver->Resolve(env()->context(), value).FromJust());
}
Expand All @@ -255,9 +265,13 @@ void FSReqPromise<AliasedBufferT>::ResolveStatFs(const uv_statfs_t* stat) {
template <typename AliasedBufferT>
void FSReqPromise<AliasedBufferT>::SetReturnValue(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Local<v8::Value> val =
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
v8::Local<v8::Value> val;
if (!object()->Get(env()->context(), env()->promise_string()).ToLocal(&val)) {
// If we hit this, getting the value from the object failed and
// an error was likely scheduled. We could try to reject the promise
// but let's just allow the error to propagate.
return;
}
v8::Local<v8::Promise::Resolver> resolver = val.As<v8::Promise::Resolver>();
args.GetReturnValue().Set(resolver->GetPromise());
}
Expand Down
33 changes: 22 additions & 11 deletions 33 src/node_file.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {

auto maybe_resolver = Promise::Resolver::New(context);
CHECK(!maybe_resolver.IsEmpty());
Local<Promise::Resolver> resolver = maybe_resolver.ToLocalChecked();
Local<Promise::Resolver> resolver;
if (!maybe_resolver.ToLocal(&resolver)) return {};
Local<Promise> promise = resolver.As<Promise>();

Local<Object> close_req_obj;
Expand Down Expand Up @@ -845,10 +846,12 @@ void AfterStringPath(uv_fs_t* req) {
req->path,
req_wrap->encoding(),
&error);
if (link.IsEmpty())
if (link.IsEmpty()) {
req_wrap->Reject(error);
else
req_wrap->Resolve(link.ToLocalChecked());
} else {
Local<Value> val;
if (link.ToLocal(&val)) req_wrap->Resolve(val);
}
}
}

Expand All @@ -865,10 +868,12 @@ void AfterStringPtr(uv_fs_t* req) {
static_cast<const char*>(req->ptr),
req_wrap->encoding(),
&error);
if (link.IsEmpty())
if (link.IsEmpty()) {
req_wrap->Reject(error);
else
req_wrap->Resolve(link.ToLocalChecked());
} else {
Local<Value> val;
if (link.ToLocal(&val)) req_wrap->Resolve(val);
}
}
}

Expand Down Expand Up @@ -2262,7 +2267,8 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
MaybeStackBuffer<uv_buf_t> iovs(chunks->Length());

for (uint32_t i = 0; i < iovs.length(); i++) {
Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();
Local<Value> chunk;
if (!chunks->Get(env->context(), i).ToLocal(&chunk)) return;
CHECK(Buffer::HasInstance(chunk));
iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk));
}
Expand Down Expand Up @@ -2602,8 +2608,12 @@ static void ReadFileUtf8(const FunctionCallbackInfo<Value>& args) {
}
FS_SYNC_TRACE_END(read);

args.GetReturnValue().Set(
ToV8Value(env->context(), result, isolate).ToLocalChecked());
Local<Value> val;
if (!ToV8Value(env->context(), result, isolate).ToLocal(&val)) {
return;
}

args.GetReturnValue().Set(val);
}

// Wrapper for readv(2).
Expand Down Expand Up @@ -2631,7 +2641,8 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {

// Init uv buffers from ArrayBufferViews
for (uint32_t i = 0; i < iovs.length(); i++) {
Local<Value> buffer = buffers->Get(env->context(), i).ToLocalChecked();
Local<Value> buffer;
if (!buffers->Get(env->context(), i).ToLocal(&buffer)) return;
CHECK(Buffer::HasInstance(buffer));
iovs[i] = uv_buf_init(Buffer::Data(buffer), Buffer::Length(buffer));
}
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.