From d205e502ac9a611b814be54e3a1c91b62e3c189c Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 24 Jan 2021 10:00:57 -0800 Subject: [PATCH] buffer: avoid creating the backing store in the thread Fixes: https://github.com/nodejs/node/issues/37030 --- src/node_blob.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node_blob.cc b/src/node_blob.cc index b147b8764a7668..0a360e7518770e 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -255,7 +255,6 @@ void FixedSizeBlobCopyJob::AfterThreadPoolWork(int status) { void FixedSizeBlobCopyJob::DoThreadPoolWork() { Environment* env = AsyncWrap::env(); - destination_ = ArrayBuffer::NewBackingStore(env->isolate(), length_); unsigned char* dest = static_cast(destination_->Data()); if (length_ > 0) { size_t total = 0; @@ -314,6 +313,8 @@ void FixedSizeBlobCopyJob::Run(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); FixedSizeBlobCopyJob* job; ASSIGN_OR_RETURN_UNWRAP(&job, args.Holder()); + job->destination_ = + ArrayBuffer::NewBackingStore(env->isolate(), job->length_); if (job->mode() == FixedSizeBlobCopyJob::Mode::ASYNC) return job->ScheduleWork();