Skip to content

Commit adba5c4

Browse files
Copilotalexr00
andauthored
Suppress RemoveReaction permission errors during rapid reaction toggling (#8225)
* Initial plan * Initial plan for handling reaction permission errors Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix: Ignore GraphQL permission error when quickly toggling reactions When users quickly click on a reaction to add/remove it, a race condition can occur where the client tries to remove a reaction that the user doesn't have permission to remove. This results in a GraphQL error: "does not have the correct permissions to execute 'RemoveReaction'" This change silently ignores this specific error as it's expected behavior during rapid toggling of reactions. Fixes microsoft/vscode#69321 Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Refactor: Use consistent error handling in both toggleReaction implementations - Import formatError in pullRequestCommentController.ts - Use formatError(e) consistently in both implementations - Throw new Error(errorMessage) consistently instead of rethrowing original error Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix message --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent e30b8f8 commit adba5c4

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

src/view/pullRequestCommentController.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { disposeAll } from '../common/lifecycle';
1212
import Logger from '../common/logger';
1313
import { ITelemetry } from '../common/telemetry';
1414
import { fromPRUri, Schemes } from '../common/uri';
15-
import { groupBy } from '../common/utils';
15+
import { formatError, groupBy } from '../common/utils';
1616
import { PULL_REQUEST_OVERVIEW_VIEW_TYPE } from '../common/webview';
1717
import { FolderRepositoryManager } from '../github/folderRepositoryManager';
1818
import { GitHubRepository } from '../github/githubRepository';
@@ -546,14 +546,25 @@ export class PullRequestCommentController extends CommentControllerBase implemen
546546
return;
547547
}
548548

549-
if (
550-
comment.reactions &&
551-
!comment.reactions.find(ret => ret.label === reaction.label && !!ret.authorHasReacted)
552-
) {
553-
// add reaction
554-
await this.pullRequestModel.addCommentReaction(comment.rawComment.graphNodeId, reaction);
555-
} else {
556-
await this.pullRequestModel.deleteCommentReaction(comment.rawComment.graphNodeId, reaction);
549+
try {
550+
if (
551+
comment.reactions &&
552+
!comment.reactions.find(ret => ret.label === reaction.label && !!ret.authorHasReacted)
553+
) {
554+
// add reaction
555+
await this.pullRequestModel.addCommentReaction(comment.rawComment.graphNodeId, reaction);
556+
} else {
557+
await this.pullRequestModel.deleteCommentReaction(comment.rawComment.graphNodeId, reaction);
558+
}
559+
} catch (e) {
560+
// Ignore permission errors when removing reactions due to race conditions
561+
// See: https://github.com/microsoft/vscode/issues/69321
562+
const errorMessage = formatError(e);
563+
if (errorMessage.includes('does not have the correct permissions to execute `RemoveReaction`')) {
564+
// Silently ignore this error - it occurs when quickly toggling reactions
565+
return;
566+
}
567+
throw new Error(errorMessage);
557568
}
558569
}
559570

src/view/reviewCommentController.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,14 @@ ${suggestionInformation.suggestionContent}
985985
);
986986
}
987987
} catch (e) {
988-
throw new Error(formatError(e));
988+
// Ignore permission errors when removing reactions due to race conditions
989+
// See: https://github.com/microsoft/vscode/issues/69321
990+
const errorMessage = formatError(e);
991+
if (errorMessage.includes('does not have the correct permissions to execute `RemoveReaction`')) {
992+
// Silently ignore this error - it occurs when quickly toggling reactions
993+
return;
994+
}
995+
throw new Error(errorMessage);
989996
}
990997
}
991998

0 commit comments

Comments
 (0)