Repository navigation
fix(hub): cancel superseded collaborator searches - #349
zachshallbetter wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Cancellation does not cover the full mention request or installation-token minting, allowing abandoned requests to continue or initiate unnecessary GitHub calls.
2 open issues
What changed in this PR
This PR adds disconnect-driven cancellation to Hub’s review mention searches, reducing unnecessary GitHub collaborator paging when reviewers keep typing. It addresses #328 while retaining existing search limits, repository access checks, and save-time mention verification.
Changes:
- Passes browser-disconnect cancellation through the mention directory to GitHub requests.
- Stops collaborator pagination after cancellation.
- Adds a disconnect regression test and documents the behavior.
| File | Description |
|---|---|
hub/server/routes/api/review-comments/collaboration.db.test.ts |
Tests cancellation and prevention of further paging after disconnect. |
hub/server/routes/api/review-comments/collaboration-handlers/index.ts |
Tracks disconnects and avoids responding to destroyed connections. |
hub/server/integrations/github/create-review-directory/types.ts |
Adds an optional cancellation signal to collaborator searches. |
hub/server/integrations/github/create-review-directory/index.ts |
Combines cancellation with timeouts and checks before further paging. |
hub/server/domains/review-comments/create-review-mention-directory/index.ts |
Forwards cancellation to the GitHub directory. |
hub/docs/review-collaboration.md |
Documents disconnect cancellation for collaborator lookups. |
Review effort: Max (adaptive)
| async search(repositoryId, query, cancellation) { | ||
| cancellation?.throwIfAborted() | ||
| const timeout = AbortSignal.timeout(6000) | ||
| const signal = cancellation ? AbortSignal.any([timeout, cancellation]) : timeout |
| cancellation.abort() | ||
| } | ||
| // The incoming GET can finish before its client disconnects. | ||
| response.once("close", cancel) |
|
I pushed |
|
Could someone approve the CI runs for |
nshki
left a comment
There was a problem hiding this comment.
Thanks so much for opening this PR, @zachshallbetter! After taking a look, I dug a bit more to see whether we could avoid the inefficient query in the first place. Based on the default GitHub App permissions we request for new Hub installations, it looks like we should be able to use GitHub’s GraphQL Repository.collaborators(query: ...) field instead of fetching broad REST pages and filtering them in Hub.
Could you investigate using the filtered GraphQL query here? It may address the unnecessary pagination more directly than cancellation.

Why
When reviewers keep typing a mention, the browser drops the old search. Hub can still page through GitHub collaborators for every abandoned search, using the same rate limit as the current one.
Addresses #328.
What changes
Hub cancels the in-flight collaborator lookup when the browser disconnects and skips any remaining pages. Connected searches keep their existing limits and repository access checks. Hub still verifies mentions when a comment is saved.