Skip to content

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