Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bea2501

Browse filesBrowse files
committed
src: no SetImmediate from destructor in stream_pipe code
Guard against running `SetImmediate()` from the destructor. The object will not be alive or usable in the callback, so it does not make sense to attempt to schedule the `SetImmediate()`. PR-URL: #30666 Fixes: #30643 Refs: #30374 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 94357db commit bea2501
Copy full SHA for bea2501

File tree

Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed
Open diff view settings
Collapse file

‎src/stream_pipe.cc‎

Copy file name to clipboardExpand all lines: src/stream_pipe.cc
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ StreamPipe::StreamPipe(StreamBase* source,
4242
}
4343

4444
StreamPipe::~StreamPipe() {
45-
Unpipe();
45+
Unpipe(true);
4646
}
4747

4848
StreamBase* StreamPipe::source() {
@@ -53,7 +53,7 @@ StreamBase* StreamPipe::sink() {
5353
return static_cast<StreamBase*>(writable_listener_.stream());
5454
}
5555

56-
void StreamPipe::Unpipe() {
56+
void StreamPipe::Unpipe(bool is_in_deletion) {
5757
if (is_closed_)
5858
return;
5959

@@ -68,6 +68,8 @@ void StreamPipe::Unpipe() {
6868
source()->RemoveStreamListener(&readable_listener_);
6969
sink()->RemoveStreamListener(&writable_listener_);
7070

71+
if (is_in_deletion) return;
72+
7173
// Delay the JS-facing part with SetImmediate, because this might be from
7274
// inside the garbage collector, so we can’t run JS here.
7375
HandleScope handle_scope(env()->isolate());
Collapse file

‎src/stream_pipe.h‎

Copy file name to clipboardExpand all lines: src/stream_pipe.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class StreamPipe : public AsyncWrap {
1212
StreamPipe(StreamBase* source, StreamBase* sink, v8::Local<v8::Object> obj);
1313
~StreamPipe() override;
1414

15-
void Unpipe();
15+
void Unpipe(bool is_in_deletion = false);
1616

1717
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
1818
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.