Skip to content

Commit a624277

Browse files
targosnodejs-github-bot
authored andcommitted
src: fix ArrayBuffer::Detach deprecation
PR-URL: #45579 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent eca6180 commit a624277

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/js_native_api_v8.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3239,7 +3239,7 @@ napi_status NAPI_CDECL napi_detach_arraybuffer(napi_env env,
32393239
RETURN_STATUS_IF_FALSE(
32403240
env, it->IsDetachable(), napi_detachable_arraybuffer_expected);
32413241

3242-
it->Detach();
3242+
it->Detach(v8::Local<v8::Value>()).Check();
32433243

32443244
return napi_clear_last_error(env);
32453245
}

src/node_blob.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ void Blob::New(const FunctionCallbackInfo<Value>& args) {
107107
CHECK_EQ(view->ByteOffset(), 0);
108108
std::shared_ptr<BackingStore> store = view->Buffer()->GetBackingStore();
109109
size_t byte_length = view->ByteLength();
110-
view->Buffer()->Detach(); // The Blob will own the backing store now.
110+
view->Buffer()
111+
->Detach(Local<Value>())
112+
.Check(); // The Blob will own the backing store now.
111113
entries.emplace_back(BlobEntry{std::move(store), byte_length, 0});
112114
len += byte_length;
113115
} else {

src/node_buffer.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Local<ArrayBuffer> CallbackInfo::CreateTrackedArrayBuffer(
125125
// V8 simply ignores the BackingStore deleter callback if data == nullptr,
126126
// but our API contract requires it being called.
127127
if (data == nullptr) {
128-
ab->Detach();
128+
ab->Detach(Local<Value>()).Check();
129129
self->OnBackingStoreFree(); // This calls `callback` asynchronously.
130130
} else {
131131
// Store the ArrayBuffer so that we can detach it later.
@@ -156,7 +156,7 @@ void CallbackInfo::CleanupHook(void* data) {
156156
HandleScope handle_scope(self->env_->isolate());
157157
Local<ArrayBuffer> ab = self->persistent_.Get(self->env_->isolate());
158158
if (!ab.IsEmpty() && ab->IsDetachable()) {
159-
ab->Detach();
159+
ab->Detach(Local<Value>()).Check();
160160
self->persistent_.Reset();
161161
}
162162
}
@@ -1256,7 +1256,7 @@ void DetachArrayBuffer(const FunctionCallbackInfo<Value>& args) {
12561256
Local<ArrayBuffer> buf = args[0].As<ArrayBuffer>();
12571257
if (buf->IsDetachable()) {
12581258
std::shared_ptr<BackingStore> store = buf->GetBackingStore();
1259-
buf->Detach();
1259+
buf->Detach(Local<Value>()).Check();
12601260
args.GetReturnValue().Set(ArrayBuffer::New(env->isolate(), store));
12611261
}
12621262
}

src/node_messaging.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ Maybe<bool> Message::Serialize(Environment* env,
516516
for (Local<ArrayBuffer> ab : array_buffers) {
517517
// If serialization succeeded, we render it inaccessible in this Isolate.
518518
std::shared_ptr<BackingStore> backing_store = ab->GetBackingStore();
519-
ab->Detach();
519+
ab->Detach(Local<Value>()).Check();
520520

521521
array_buffers_.emplace_back(std::move(backing_store));
522522
}

0 commit comments

Comments
 (0)