chore(aio): flush Convex telemetry before action return - #71433
Conversation
🤖 CI reportℹ️ Docs preview — preview build triggeredDocs from this PR will be published at posthog.com.
The preview should be ready in about 10 minutes. Open the preview at |
|
Reviews (1): Last reviewed commit: "Merge branch 'master' into docs/convex-f..." | Re-trigger Greptile |
| }, | ||
| }) | ||
|
|
||
| await provider.forceFlush() |
There was a problem hiding this comment.
Telemetry Failure Rejects Action
When the OTLP exporter fails or times out, the awaited forceFlush() can reject after the model has already produced a valid result. That rejection makes the Convex action fail instead of returning the generated response. Isolate this best-effort telemetry failure from the action result; the second example has the same failure path.
Rule Used: Always wrap asynchronous calls that may fail, such... (source)
Learned From
PostHog/posthog#32098
Problem
Convex actions can finish while OpenTelemetry exports are still pending, which can drop AI observability spans.
Changes
Flush both Convex action examples before returning.
How did you test this code?
pnpm exec oxfmt --check docs/onboarding/ai-observability/convex.tsxpnpm exec oxlint --quiet docs/onboarding/ai-observability/convex.tsxgit diff --check👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
Updates the Convex AI observability installation guide.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Codex prepared and published this docs-only change using
/posthog-support-answer,/slack, and/yeet.