GeezerVison is showing github.com — fix(gitlab): preserve rate limits when reading thread refs · pingdotgg/t3code@8a773f0
File treeExpand file treeCollapse file tree Open diff view settings packages/source-control-gitlab/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts +24-1Lines changed: 24 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -930,7 +930,7 @@ layer("GitLabPullRequestCli.layer", (it) => { | 930 | 930 | ); | 931 | 931 |
| 932 | 932 | it.effect( | 933 | | - "keeps discussions current when the merge request's diff refs are missing or unreadable", | | 933 | + "keeps discussions current for unreadable refs but propagates CLI requirements and rate limits", | 934 | 934 | () => | 935 | 935 | Effect.gen(function* () { | 936 | 936 | const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli; | @@ -971,6 +971,29 @@ layer("GitLabPullRequestCli.layer", (it) => { | 971 | 971 |
| 972 | 972 | expect(threads.map((thread) => [thread.id, thread.isOutdated])).toEqual([["abc", false]]); | 973 | 973 | } | | 974 | + const context = { | | 975 | + operation: "execute" as const, | | 976 | + command: "glab" as const, | | 977 | + cwd: "/w", | | 978 | + cause: new Error("unavailable"), | | 979 | + }; | | 980 | + for (const error of [ | | 981 | + new GitLabCli.GitLabCliUnavailableError(context), | | 982 | + new GitLabCli.GitLabCliAuthenticationError(context), | | 983 | + new GitLabCli.GitLabCliRateLimitError(context), | | 984 | + ]) { | | 985 | + mockedExecute.mockImplementation(({ args }) => | | 986 | + args[1]?.includes("/discussions") ? Effect.succeed(output("[]")) : Effect.fail(error), | | 987 | + ); | | 988 | + expect( | | 989 | + yield* Effect.result( | | 990 | + cli.listDiscussions({ cwd: "/w", repository: "acme/web", number: 7 }), | | 991 | + ), | | 992 | + ).toMatchObject({ | | 993 | + _tag: "Failure", | | 994 | + failure: error, | | 995 | + }); | | 996 | + } | 974 | 997 | }), | 975 | 998 | ); | 976 | 999 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts +10-1Lines changed: 10 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1731,7 +1731,16 @@ export const make = Effect.gen(function* () { | 1731 | 1731 | discussionsPage({ ...input, page: 1, collected: [], diffRefsByThreadId: new Map() }), | 1732 | 1732 | // Fresh beside the discussions: cached refs from before a push would invert every flag. | 1733 | 1733 | // Unreadable refs leave threads current rather than hiding them. | 1734 | | - getDiffRefs(input).pipe(Effect.orElseSucceed(() => null)), | | 1734 | + getDiffRefs(input).pipe( | | 1735 | + Effect.catchTags( | | 1736 | + { | | 1737 | + GitLabCliUnavailableError: (error) => Effect.fail(error), | | 1738 | + GitLabCliAuthenticationError: (error) => Effect.fail(error), | | 1739 | + GitLabCliRateLimitError: (error) => Effect.fail(error), | | 1740 | + }, | | 1741 | + () => Effect.succeed(null), | | 1742 | + ), | | 1743 | + ), | 1735 | 1744 | ], | 1736 | 1745 | { concurrency: 2 }, | 1737 | 1746 | ); | |
|