You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: ensure node and services are watcing for the same shutdown signal from the context cancel (#1406)
<!--
Please read and fill out this form before submitting your PR.
Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->
## Overview
<!--
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue.
-->
The nodes were creating a new context with cancel after passing the
original context through to the services. This meant that when the node
shutdown and cancelled its context, its services did not receive a
shutdown signal until the original caller cancelled its context. This
was leading to panics in testing about writing to a logger test file
that was already closed.
This change was verified by reverting the changes in #1402 and testing
in a loop 100 times with no panics.
**EDIT 1**
Since no good deed goes unpunished 🙃 some timeouts surfaced. This was
due to `context.Background()` being used for subscribe and unsubscribe
events. Under the hood those events are watching for `ctx.Done()`
events, so when `context.Background()` is passed in, they can hang
indefinitely if the other signals aren't triggered. The test that was
most prone to this timeout was run in a loop 1000 times to verify the
issue was fixed.
Additionally, added some more checks for `ctx.Done()` for faster
shutdowns.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Enhanced node shutdown process with context cancellation for improved
service termination.
- **Refactor**
- Updated error handling and context management in node creation
functions.
- Improved context usage in block synchronization and event subscription
methods.
- **Tests**
- Adjusted full node integration tests to reflect new context
management.
- **Chores**
- Removed redundant node cancellation in test cleanup function.
- **Documentation**
- No visible changes to end-users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments