LukeMathWalker / LukeMathWalker/wiremock-rs

Cannot stop the server

Open
#142 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
799
Forks
91
PR merge metrics
No merged PRs in 30d

Description

Hey, as in issue title. I wanted to test that a service gracefully handles networking issues like server being temporarily unreachable and wanted to do that by dropping the `MockServer`, however this loop actually never finishes:
```rs
use std::time::Duration;

use tokio::{net::TcpStream, time::sleep};
use wiremock::MockServer;

#[tokio::main]
async fn main() {
let server = MockServer::start().await;
let addr = *server.address();

drop(server);

loop {
if TcpStream::connect(addr).await.is_err() {
break;
}
sleep(Duration::from_millis(200)).await;
println!("retrying");
}
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MockServer::start().await and MockServer::address() in the reproduction; verify what dropping MockServer is expected to do and why TcpStream::connect(addr) remains successful. Reproduce the loop, then check that the lifecycle behavior is corrected so dropping the server makes the connection fail and the loop exits.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.