Skip to content

fix(api): make Slack connection check resilient to transient failures#786

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/slack-check-transient-resilience
Draft

fix(api): make Slack connection check resilient to transient failures#786
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/slack-check-transient-resilience

Conversation

@posthog

@posthog posthog Bot commented Jul 1, 2026

Copy link
Copy Markdown

Problem

The Slack-connection check on the post-install step (fetchSlackConnected in src/lib/api.ts) issued a bare axios.get against /api/projects/:id/integrations/ with no timeout, retry, or transient-failure handling. Any flaky request — a gateway 504, a socket reset, a TLS-handshake disconnect — threw, and the SlackConnectScreen poll caught it and called captureException. The wizard already degrades gracefully to the connect nudge, so this was purely error-tracking noise: it turned routine network blips on a non-critical step into tracked exceptions, split across several error classes and per-release bundle filenames.

Changes

  • Make fetchSlackConnected resilient to all transient failures: a short request timeout plus a small retry/backoff for gateway 5xx (502/503/504) and retryable socket/TLS errors (ECONNRESET, EADDRNOTAVAIL, ETIMEDOUT, axios timeouts, TLS-handshake disconnects, DNS blips).
  • Exhausted transient failures now degrade quietly to "not connected" (return false) without calling captureException. Exception reporting is reserved for genuine, non-transient errors (401/403, malformed responses).
  • Caller-initiated aborts (screen teardown) propagate as cancellations for the poll's existing teardown guard to swallow.
  • Updated the SlackConnectScreen catch comment to reflect that only genuine errors now reach it.

This changes what gets reported, not the UX — the fallback nudge already covered the degraded path.

Test plan

New unit tests in src/lib/__tests__/fetch-slack-connected.test.ts cover: success, retry-then-succeed, quiet degrade across each transient failure mode (504/502/503, EADDRNOTAVAIL, ECONNRESET, axios timeout, TLS disconnect), throw-on-genuine (401/403/404, malformed 200), cancellation propagation, and the already-aborted guard. pnpm build && pnpm test — all 1141 tests pass; pnpm fix clean.


Created with PostHog Code from an inbox report.

`fetchSlackConnected` issued a bare `axios.get` with no timeout or retry, so
any transient network blip against `/integrations/` threw and the callers
captured it as an exception. On a non-critical post-install poll that already
degrades gracefully to the connect nudge, this produced steadily accumulating
error-tracking noise across several transient failure modes (gateway 504s,
socket resets, TLS-handshake disconnects).

Add a short timeout plus a small retry/backoff for gateway 5xx and retryable
socket/TLS errors. Exhausted transient failures now degrade quietly to
"not connected" without calling `captureException`; only genuine,
non-transient errors (401/403, malformed responses) still throw for the
caller to report.

Generated-By: PostHog Code
Task-Id: 54188ec4-3681-47ed-9228-a0628b42af27
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci mcp-analytics
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/cicd-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-nested-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-single-stage-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-gitlab-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-pnpm-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-raw-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-ssh-vps-node-raw
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants