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 <yagiz@nizipli.com>
This commit is contained in:
Joyee Cheung authored and Ruy Adorno committed 2023-09-27 22:20:18 -04:00
1 parent 3987094569
commit 39fb83ad16
1 file changed
+1 -2
+1 -2
View File
@@ -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>();
}