Skip to content

Commit fb2f0af

Browse files
committed
fix
1 parent b582858 commit fb2f0af

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

apps/dashboard/src/lib/github.functions.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,16 +1703,19 @@ async function executeGitHubGraphQL<TResponse>(
17031703
}
17041704

17051705
/**
1706-
* Fire-and-forget persistence so the OAuth fallback can skip these orgs on
1707-
* future fetches (see `getMySearchSources`). Errors are logged but never
1708-
* propagate — this is best-effort optimization, not correctness-critical.
1706+
* Persist orgs that returned an OAuth restriction so the OAuth fallback can
1707+
* skip them on future fetches (see `getMySearchSources`). Awaited inline —
1708+
* the worker is configured with `no_handle_cross_request_promise_resolution`
1709+
* so a fire-and-forget write would race the response and get cancelled.
1710+
* Errors are swallowed: this is best-effort optimization, not correctness.
17091711
*/
1710-
function persistForbiddenOrgs(userId: string, orgs: string[]) {
1711-
void import("./forbidden-orgs-store")
1712-
.then(({ recordForbiddenOrgs }) => recordForbiddenOrgs(userId, orgs))
1713-
.catch((error) => {
1714-
console.error("[github-search] failed to persist forbidden orgs", error);
1715-
});
1712+
async function persistForbiddenOrgs(userId: string, orgs: string[]) {
1713+
try {
1714+
const { recordForbiddenOrgs } = await import("./forbidden-orgs-store");
1715+
await recordForbiddenOrgs(userId, orgs);
1716+
} catch (error) {
1717+
console.error("[github-search] failed to persist forbidden orgs", error);
1718+
}
17161719
}
17171720

17181721
/**
@@ -4934,14 +4937,14 @@ async function getMySearchSources(
49344937
}
49354938
}
49364939
if (recovered.length > 0) {
4937-
void clearForbiddenOrgsForUser(context.session.user.id, recovered).catch(
4938-
(error) => {
4939-
console.error(
4940-
"[github-search] failed to clear recovered forbidden orgs",
4941-
error,
4942-
);
4943-
},
4944-
);
4940+
try {
4941+
await clearForbiddenOrgsForUser(context.session.user.id, recovered);
4942+
} catch (error) {
4943+
console.error(
4944+
"[github-search] failed to clear recovered forbidden orgs",
4945+
error,
4946+
);
4947+
}
49454948
}
49464949
for (const org of stillForbidden) {
49474950
addExcludedOwnerScope(excludedOAuthOwners, {
@@ -5233,7 +5236,10 @@ async function getMyPullsResult({
52335236
if (forbiddenOrgs.length > 0) {
52345237
const uniqueForbiddenOrgs = [...new Set(forbiddenOrgs)];
52355238
data.forbiddenOrgs = uniqueForbiddenOrgs;
5236-
void persistForbiddenOrgs(context.session.user.id, uniqueForbiddenOrgs);
5239+
await persistForbiddenOrgs(
5240+
context.session.user.id,
5241+
uniqueForbiddenOrgs,
5242+
);
52375243
}
52385244
if (results.length < sources.length) {
52395245
data.partial = true;
@@ -5411,7 +5417,10 @@ async function getMyIssuesResult({
54115417
if (forbiddenOrgs.length > 0) {
54125418
const uniqueForbiddenOrgs = [...new Set(forbiddenOrgs)];
54135419
data.forbiddenOrgs = uniqueForbiddenOrgs;
5414-
void persistForbiddenOrgs(context.session.user.id, uniqueForbiddenOrgs);
5420+
await persistForbiddenOrgs(
5421+
context.session.user.id,
5422+
uniqueForbiddenOrgs,
5423+
);
54155424
}
54165425
if (results.length < sources.length) {
54175426
data.partial = true;

0 commit comments

Comments
 (0)