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

query: also teard down on ctx done #106

Merged
merged 1 commit into from
May 13, 2022
Merged

Conversation

MichaelMure
Copy link
Contributor

I'm not entirely sure this should be supported but at the moment you could expect to terminate a query:

  • call Close() on the Result
  • cancel the context

The second one though doesn't work as cancelling the context doesn't kill the query. This PR address that problem.

@guseggert
Copy link
Contributor

guseggert commented May 10, 2022

Have you gone through where this is (potentially) used to make sure that returning context.Canceled or context.DeadlineExceeded are handled gracefully/correctly upstream? Would it make sense to just swallow ctx.Err() and return nothing? (which is what happens when results.Close() is called, also what happens on processctx.WithContext(ctx))

@MichaelMure
Copy link
Contributor Author

My thinking is that calling results.Close() is a voluntary action from the caller side.

On the other hand, killing a query with the context is typically done higher in the call stack, with a timeout or linked to a request lifecycle. There, the caller side might not know and an error would help distinguish a success or failure termination.

@guseggert
Copy link
Contributor

I did some spot checking of how these bubble up into go-ipfs and it looks okay to me. Thanks!

@guseggert guseggert merged commit 9e51ebb into ipfs:master May 13, 2022
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.

2 participants