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.
  • Loading branch information
joyeecheung committed Aug 26, 2023
1 parent 5ff1ead commit 7fc751d
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 7fc751d

Please sign in to comment.