mirror of https://github.com/nodejs/node.git
src: fix ArrayBuffer::Detach deprecation
PR-URL: https://github.com/nodejs/node/pull/45579 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
eca618071e
commit
a6242772ec
|
@ -3239,7 +3239,7 @@ napi_status NAPI_CDECL napi_detach_arraybuffer(napi_env env,
|
|||
RETURN_STATUS_IF_FALSE(
|
||||
env, it->IsDetachable(), napi_detachable_arraybuffer_expected);
|
||||
|
||||
it->Detach();
|
||||
it->Detach(v8::Local<v8::Value>()).Check();
|
||||
|
||||
return napi_clear_last_error(env);
|
||||
}
|
||||
|
|
|
@ -107,7 +107,9 @@ void Blob::New(const FunctionCallbackInfo<Value>& args) {
|
|||
CHECK_EQ(view->ByteOffset(), 0);
|
||||
std::shared_ptr<BackingStore> store = view->Buffer()->GetBackingStore();
|
||||
size_t byte_length = view->ByteLength();
|
||||
view->Buffer()->Detach(); // The Blob will own the backing store now.
|
||||
view->Buffer()
|
||||
->Detach(Local<Value>())
|
||||
.Check(); // The Blob will own the backing store now.
|
||||
entries.emplace_back(BlobEntry{std::move(store), byte_length, 0});
|
||||
len += byte_length;
|
||||
} else {
|
||||
|
|
|
@ -125,7 +125,7 @@ Local<ArrayBuffer> CallbackInfo::CreateTrackedArrayBuffer(
|
|||
// V8 simply ignores the BackingStore deleter callback if data == nullptr,
|
||||
// but our API contract requires it being called.
|
||||
if (data == nullptr) {
|
||||
ab->Detach();
|
||||
ab->Detach(Local<Value>()).Check();
|
||||
self->OnBackingStoreFree(); // This calls `callback` asynchronously.
|
||||
} else {
|
||||
// Store the ArrayBuffer so that we can detach it later.
|
||||
|
@ -156,7 +156,7 @@ void CallbackInfo::CleanupHook(void* data) {
|
|||
HandleScope handle_scope(self->env_->isolate());
|
||||
Local<ArrayBuffer> ab = self->persistent_.Get(self->env_->isolate());
|
||||
if (!ab.IsEmpty() && ab->IsDetachable()) {
|
||||
ab->Detach();
|
||||
ab->Detach(Local<Value>()).Check();
|
||||
self->persistent_.Reset();
|
||||
}
|
||||
}
|
||||
|
@ -1256,7 +1256,7 @@ void DetachArrayBuffer(const FunctionCallbackInfo<Value>& args) {
|
|||
Local<ArrayBuffer> buf = args[0].As<ArrayBuffer>();
|
||||
if (buf->IsDetachable()) {
|
||||
std::shared_ptr<BackingStore> store = buf->GetBackingStore();
|
||||
buf->Detach();
|
||||
buf->Detach(Local<Value>()).Check();
|
||||
args.GetReturnValue().Set(ArrayBuffer::New(env->isolate(), store));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,7 +516,7 @@ Maybe<bool> Message::Serialize(Environment* env,
|
|||
for (Local<ArrayBuffer> ab : array_buffers) {
|
||||
// If serialization succeeded, we render it inaccessible in this Isolate.
|
||||
std::shared_ptr<BackingStore> backing_store = ab->GetBackingStore();
|
||||
ab->Detach();
|
||||
ab->Detach(Local<Value>()).Check();
|
||||
|
||||
array_buffers_.emplace_back(std::move(backing_store));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue