src: keep object alive in stream_pipe code

This was overlooked in a489583eda.

Refs: https://github.com/nodejs/node/pull/30374

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/30666
Fixes: https://github.com/nodejs/node/issues/30643
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen authored and Myles Borins committed 2020-04-01 17:36:45 -04:00
1 parent 5f95e69f4d
commit 7647bfe3fc
1 file changed
+1 -1
+1 -1
View File
@@ -73,7 +73,7 @@ void StreamPipe::Unpipe() {
// inside the garbage collector, so we can’t run JS here.
HandleScope handle_scope(env()->isolate());
BaseObjectPtr<StreamPipe> 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> object = this->object();