From 39fb83ad168ea199cfb10ee1f331cfb1db1232a8 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 7 Sep 2023 10:59:38 +0200 Subject: [PATCH] src: do not rely on the internal field being default to undefined 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: https://github.com/nodejs/node/pull/49413 Refs: https://chromium-review.googlesource.com/c/v8/v8/+/4707972/comment/be9285cc_a49aad88/ Reviewed-By: Yagiz Nizipli --- src/node_file.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 285e532f007..a6f801148b9 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -457,8 +457,7 @@ MaybeLocal FileHandle::ClosePromise() { Local close_resolver = object()->GetInternalField(FileHandle::kClosingPromiseSlot).As(); - if (!close_resolver.IsEmpty() && !close_resolver->IsUndefined()) { - CHECK(close_resolver->IsPromise()); + if (close_resolver->IsPromise()) { return close_resolver.As(); }