Skip to content

Commit

Permalink
[hack] fix ArrayBuffer::Detach deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
targos authored and nodejs-github-bot committed Nov 16, 2022
1 parent 1a767ce commit ce32638
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ 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 {
Expand Down
6 changes: 3 additions & 3 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -1255,7 +1255,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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit ce32638

Please sign in to comment.