Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fire shutdown signal on anvil node handle drop #8947

Merged
merged 7 commits into from
Sep 25, 2024

Conversation

grandizzy
Copy link
Collaborator

Motivation

ref #8946 (review)

Solution

@grandizzy grandizzy changed the title chore: add anvil NodeHandle.fire_shutdown_signal chore: add anvil NodeHandle.fire_shutdown_signal Sep 24, 2024
@grandizzy grandizzy marked this pull request as ready for review September 24, 2024 10:43
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: why is this not called on Drop?

crates/anvil/src/lib.rs Outdated Show resolved Hide resolved
crates/anvil/src/lib.rs Outdated Show resolved Hide resolved
///
/// Called by long-running tests to make sure anvil instance is terminated.
#[track_caller]
pub fn fire_shutdown_signal(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this go into an impl Drop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will do and make some tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, weird, I added in drop

+impl Drop for NodeHandle {
+    fn drop(&mut self) {
+        if let Some(signal) = self._signal.take() {
+            signal.fire().unwrap()
+        }
+    }
+}

and then got again a failure like

failed to spawn node: Os { code: 98, kind: AddrInUse, message: "Address already in use" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    proof::test_account_proof

going to make some more tests to see if consistently happens

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in 277d62c ptal

@grandizzy grandizzy changed the title chore: add anvil NodeHandle.fire_shutdown_signal chore: fire shutdown signal on anvil node handle drop Sep 25, 2024
@grandizzy grandizzy requested a review from DaniPopes September 25, 2024 06:51
@grandizzy grandizzy merged commit 9a0f66e into foundry-rs:master Sep 25, 2024
21 checks passed
@grandizzy grandizzy deleted the chore-shutdown-anvil branch September 25, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants