Skip to content

Commit 1be6e88

Browse files
fix(worker): properly shutdown PostHog client (#609)
1 parent f04ecab commit 1be6e88

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fixed incorrect shutdown of PostHog SDK in the worker. [#609](https://github.com/sourcebot-dev/sourcebot/pull/609)
12+
1013
## [4.9.1] - 2025-11-07
1114

1215
### Added

packages/backend/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { RepoPermissionSyncer } from './ee/repoPermissionSyncer.js';
1414
import { AccountPermissionSyncer } from "./ee/accountPermissionSyncer.js";
1515
import { PromClient } from './promClient.js';
1616
import { RepoIndexManager } from "./repoIndexManager.js";
17+
import { shutdownPosthog } from "./posthog.js";
1718

1819

1920
const logger = createLogger('backend-entrypoint');
@@ -101,6 +102,7 @@ const cleanup = async (signal: string) => {
101102

102103
await prisma.$disconnect();
103104
await redis.quit();
105+
await shutdownPosthog();
104106
}
105107

106108
process.on('SIGINT', () => cleanup('SIGINT').finally(() => process.exit(0)));

packages/backend/src/posthog.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ export function captureEvent<E extends PosthogEvent>(event: E, properties: Posth
2929
});
3030
}
3131

32-
await posthog?.shutdown();
32+
export async function shutdownPosthog() {
33+
await posthog?.shutdown();
34+
}

0 commit comments

Comments
 (0)