-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
bugSomething isn't workingSomething isn't workinggh-issuerelating to the gh issue commandrelating to the gh issue commandneeds-triageneeds to be reviewedneeds to be reviewedp3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetic
Description
Description
When running gh issue view --comments, the command first fetches the issue details including the first 100 comments. Then, it calls preloadIssueComments to fetch any additional comments if they exist.
Currently, preloadIssueComments in pkg/cmd/issue/view/http.go has a logic flaw:
- It checks if
issue.Comments.PageInfo.HasNextPageis true. - If it is false (meaning all comments were already fetched in the first request), it clears
issue.Comments.Nodesand proceeds to re-fetch them anyway!
if issue.Comments.PageInfo.HasNextPage {
variables["endCursor"] = githubv4.String(issue.Comments.PageInfo.EndCursor)
} else {
issue.Comments.Nodes = issue.Comments.Nodes[0:0] // This clears existing comments!
}This is inefficient as it makes a redundant second request even when all comments are already available.
Expected Behavior
If issue.Comments.PageInfo.HasNextPage is false, preloadIssueComments should return immediately.
If it is true, it should start fetching from the endCursor and append to the existing nodes.
Proposed Fix
Modify preloadIssueComments to return early if no more pages exist, and avoid clearing existing nodes when more pages do exist.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggh-issuerelating to the gh issue commandrelating to the gh issue commandneeds-triageneeds to be reviewedneeds to be reviewedp3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetic