Skip to content

Commit e4b88b5

Browse files
jasnelltargos
authored andcommitted
buffer: avoid creating the backing store in the thread
Fixes: #37030 PR-URL: #37052 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 55407b8 commit e4b88b5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/node_blob.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ void FixedSizeBlobCopyJob::AfterThreadPoolWork(int status) {
254254
}
255255

256256
void FixedSizeBlobCopyJob::DoThreadPoolWork() {
257-
Environment* env = AsyncWrap::env();
258-
destination_ = ArrayBuffer::NewBackingStore(env->isolate(), length_);
259257
unsigned char* dest = static_cast<unsigned char*>(destination_->Data());
260258
if (length_ > 0) {
261259
size_t total = 0;
@@ -314,6 +312,8 @@ void FixedSizeBlobCopyJob::Run(const FunctionCallbackInfo<Value>& args) {
314312
Environment* env = Environment::GetCurrent(args);
315313
FixedSizeBlobCopyJob* job;
316314
ASSIGN_OR_RETURN_UNWRAP(&job, args.Holder());
315+
job->destination_ =
316+
ArrayBuffer::NewBackingStore(env->isolate(), job->length_);
317317
if (job->mode() == FixedSizeBlobCopyJob::Mode::ASYNC)
318318
return job->ScheduleWork();
319319

0 commit comments

Comments
 (0)