fix(worker): properly shutdown PostHog client (#609)

This commit is contained in:
Brendan Kellam 2025-11-09 14:30:01 -08:00 committed by GitHub
parent f04ecab3ad
commit 1be6e8842e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- Fixed incorrect shutdown of PostHog SDK in the worker. [#609](https://github.com/sourcebot-dev/sourcebot/pull/609)
## [4.9.1] - 2025-11-07 ## [4.9.1] - 2025-11-07
### Added ### Added

View file

@ -14,6 +14,7 @@ import { RepoPermissionSyncer } from './ee/repoPermissionSyncer.js';
import { AccountPermissionSyncer } from "./ee/accountPermissionSyncer.js"; import { AccountPermissionSyncer } from "./ee/accountPermissionSyncer.js";
import { PromClient } from './promClient.js'; import { PromClient } from './promClient.js';
import { RepoIndexManager } from "./repoIndexManager.js"; import { RepoIndexManager } from "./repoIndexManager.js";
import { shutdownPosthog } from "./posthog.js";
const logger = createLogger('backend-entrypoint'); const logger = createLogger('backend-entrypoint');
@ -101,6 +102,7 @@ const cleanup = async (signal: string) => {
await prisma.$disconnect(); await prisma.$disconnect();
await redis.quit(); await redis.quit();
await shutdownPosthog();
} }
process.on('SIGINT', () => cleanup('SIGINT').finally(() => process.exit(0))); process.on('SIGINT', () => cleanup('SIGINT').finally(() => process.exit(0)));

View file

@ -29,4 +29,6 @@ export function captureEvent<E extends PosthogEvent>(event: E, properties: Posth
}); });
} }
export async function shutdownPosthog() {
await posthog?.shutdown(); await posthog?.shutdown();
}