Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(test): mock retryWithBackoff directly to prevent timeout flake (#65157)

mendral-app[bot]cdc7c4183701
diff --git a/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts b/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts
index 4a966baae356..5db78c8c1209 100644
--- a/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts
+++ b/products/logs/frontend/components/SetupPrompt/logsIngestionLogic.test.ts
@@ -7,7 +7,21 @@ import { logsIngestionLogic } from './logsIngestionLogic'
jest.mock('lib/utils/async', () => ({
...jest.requireActual('lib/utils/async'),
- delay: () => Promise.resolve(),
+ retryWithBackoff: async <T>(fn: () => Promise<T>, options: { maxAttempts?: number } = {}): Promise<T> => {
+ const maxAttempts = options.maxAttempts ?? 3
+ let lastError: unknown
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
+ try {
+ return await fn()
+ } catch (e) {
+ lastError = e
+ if (attempt >= maxAttempts - 1) {
+ throw e
+ }
+ }
+ }
+ throw lastError
+ },
}))
describe('logsIngestionLogic', () => {