Skip to content

Commit

Permalink
src: do not rely on the internal field being default to undefined
Browse files Browse the repository at this point in the history
It's an undocumented V8 behavior that is subject to change. Instead
just check if the internal field is set to a promise. There is also
no need to check IsEmpty() since the object is guaranteed to be
constructed by the FileHandle constructor with enough internal
fields.

PR-URL: #49413
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/4707972/comment/be9285cc_a49aad88/
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
joyeecheung authored Sep 7, 2023
1 parent f0ebb77 commit 941ad8b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {

Local<Value> close_resolver =
object()->GetInternalField(FileHandle::kClosingPromiseSlot).As<Value>();
if (!close_resolver.IsEmpty() && !close_resolver->IsUndefined()) {
CHECK(close_resolver->IsPromise());
if (close_resolver->IsPromise()) {
return close_resolver.As<Promise>();
}

Expand Down

0 comments on commit 941ad8b

Please sign in to comment.