Skip to content

Commit 81f3bb3

Browse files
fix
1 parent 8311979 commit 81f3bb3

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

packages/backend/src/ee/accountPermissionSyncer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class AccountPermissionSyncer {
102102
if (this.interval) {
103103
clearInterval(this.interval);
104104
}
105-
await this.worker.close();
105+
await this.worker.close(/* force = */ true);
106106
await this.queue.close();
107107
}
108108

packages/backend/src/ee/repoPermissionSyncer.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,26 @@ export class RepoPermissionSyncer {
5555
const repos = await this.db.repo.findMany({
5656
// Repos need their permissions to be synced against the code host when...
5757
where: {
58-
// They belong to a code host that supports permissions syncing
5958
AND: [
59+
// They are not public, as they are always visible to all users.
60+
// @see: packages/web/src/prisma.ts
61+
{
62+
isPublic: false
63+
},
64+
// They belong to a code host that supports permissions syncing
6065
{
6166
external_codeHostType: {
6267
in: PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES,
6368
}
6469
},
70+
// They have not been synced within the threshold date.
6571
{
6672
OR: [
6773
{ permissionSyncedAt: null },
6874
{ permissionSyncedAt: { lt: thresholdDate } },
6975
],
7076
},
77+
// There aren't any active or recently failed jobs.
7178
{
7279
NOT: {
7380
permissionSyncJobs: {
@@ -106,7 +113,7 @@ export class RepoPermissionSyncer {
106113
if (this.interval) {
107114
clearInterval(this.interval);
108115
}
109-
await this.worker.close();
116+
await this.worker.close(/* force = */ true);
110117
await this.queue.close();
111118
}
112119

packages/backend/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,36 @@ const listenToShutdownSignals = () => {
111111
await redis.quit();
112112
await api.dispose();
113113
await shutdownPosthog();
114-
115114

116115
logger.info('All workers shut down gracefully');
117116
signals.forEach(sig => process.removeListener(sig, cleanup));
117+
return 0;
118118
} catch (error) {
119119
Sentry.captureException(error);
120120
logger.error('Error shutting down worker:', error);
121+
return 1;
121122
}
122123
}
123124

124125
signals.forEach(signal => {
125126
process.on(signal, (err) => {
126-
cleanup(err).finally(() => {
127-
process.kill(process.pid, signal);
127+
cleanup(err).then(code => {
128+
process.exit(code);
128129
});
129130
});
130131
});
131132

132133
// Register handlers for uncaught exceptions and unhandled rejections
133134
process.on('uncaughtException', (err) => {
134135
logger.error(`Uncaught exception: ${err.message}`);
135-
cleanup('uncaughtException').finally(() => {
136+
cleanup('uncaughtException').then(() => {
136137
process.exit(1);
137138
});
138139
});
139140

140141
process.on('unhandledRejection', (reason, promise) => {
141142
logger.error(`Unhandled rejection at: ${promise}, reason: ${reason}`);
142-
cleanup('unhandledRejection').finally(() => {
143+
cleanup('unhandledRejection').then(() => {
143144
process.exit(1);
144145
});
145146
});

0 commit comments

Comments
 (0)