neo4j / neo4j-go-driver

Neo4j Bolt Driver for Go
Apache License 2.0
496 stars 70 forks source link

Bugfix: Retry mechanism doesn't respect the context #601

Closed SeBBBe closed 2 months ago

SeBBBe commented 2 months ago

This PR removes the Sleep func in the retry state and instead uses the following contruct to either wait the determined amount of time, or cancel if the context is canceled. I also added a test case that reproduces this scenario.

select {
case <-ctx.Done():
    s.Errs = []error{context.Canceled}
    return false
case <-time.After(sleepTime):
}