From d54432f9744374529eb3f21e0730aa11d21533c2 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 26 Nov 2019 17:00:53 +0100 Subject: [PATCH] src: keep object alive in stream_pipe code This was overlooked in a489583eda4d7cebc06516834b31dc2a4cedb1b6. Refs: https://github.com/nodejs/node/pull/30374 PR-URL: https://github.com/nodejs/node/pull/30666 Fixes: https://github.com/nodejs/node/issues/30643 Reviewed-By: Rich Trott Reviewed-By: James M Snell --- src/stream_pipe.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream_pipe.cc b/src/stream_pipe.cc index 6e339378ceb374..b84c8f4c663422 100644 --- a/src/stream_pipe.cc +++ b/src/stream_pipe.cc @@ -72,7 +72,7 @@ void StreamPipe::Unpipe() { // inside the garbage collector, so we can’t run JS here. HandleScope handle_scope(env()->isolate()); BaseObjectPtr strong_ref{this}; - env()->SetImmediate([this](Environment* env) { + env()->SetImmediate([this, strong_ref](Environment* env) { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local object = this->object();