Skip to content

Commit

Permalink
fix: destroy NodeService message pipe last (#41302)
Browse files Browse the repository at this point in the history
refactor: destroy NodeService message pipe last

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Feb 11, 2024
1 parent c9ff1d3 commit de85def
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shell/services/node/node_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class NodeService : public node::mojom::NodeService {
void Initialize(node::mojom::NodeServiceParamsPtr params) override;

private:
// This needs to be initialized first so that it can be destroyed last
// after the node::Environment is destroyed. This ensures that if
// there are crashes in the node::Environment destructor, they
// will be propagated to the exit handler.
mojo::Receiver<node::mojom::NodeService> receiver_{this};

bool node_env_stopped_ = false;

const std::unique_ptr<NodeBindings> node_bindings_;
Expand All @@ -73,8 +79,6 @@ class NodeService : public node::mojom::NodeService {

// depends-on: js_env_'s isolate
std::shared_ptr<node::Environment> node_env_;

mojo::Receiver<node::mojom::NodeService> receiver_{this};
};

} // namespace electron
Expand Down

0 comments on commit de85def

Please sign in to comment.