Skip to content

Commit 8484ab2

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

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
@@ -253,8 +253,6 @@ void FixedSizeBlobCopyJob::AfterThreadPoolWork(int status) {
253253
}
254254

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

0 commit comments

Comments
 (0)