Skip to content

fix(cloud-task): Load run history from presigned log URLs#3489

Closed
charlesvien wants to merge 3 commits into
mainfrom
fix/cloud-task-history-bootstrap
Closed

fix(cloud-task): Load run history from presigned log URLs#3489
charlesvien wants to merge 3 commits into
mainfrom
fix/cloud-task-history-bootstrap

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

Opening a cloud task with a large history can fail permanently with "Failed to load cloud run history". The bootstrap pages through the session_logs/ API, where every page makes the server re-read and re-parse the run's entire log chain from S3. On big runs a single page exceeds the 30s default authenticatedFetch timeout, and since the bootstrap is all-or-nothing and Retry restarts at offset 0, the thread becomes unopenable while the run itself is still healthy.

Changes

  • Prefer downloading history straight from the presigned resume-chain log_urls that the run detail API now returns (feat(tasks): expose resume-chain presigned log urls on run detail posthog#71394), parsing the JSONL client-side. This removes Django from the history byte path entirely and works for any history size. Falls back to the paginated API on old servers or when a download fails.
  • Paginated fallback hardening: each page gets an explicit 120s timeout instead of inheriting the 30s auth default, transient page failures retry with backoff, and fetched pages survive watcher retries so Retry resumes from the last good offset instead of restarting at 0.
  • A bootstrap generation counter discards superseded bootstrap work, since history fetches can now outlive a user-triggered retry.
  • Mobile mirrors the same strategy: chain URLs first, then the paginated API, then the legacy single log_url fallback, with the page timeout raised from 10s to 120s.

How did you test this?

Added Vitest cases in cloud-task.test.ts: bootstrap from chain URLs (including a final line without trailing newline) without touching session_logs, fallback to the paginated API when a chain download fails, and resume from the last fetched page after a watcher retry. Ran the full @posthog/core suite (2283 tests) and the mobile suite (429 tests), plus pnpm --filter @posthog/core typecheck and Biome on the changed packages. I did not manually test against a live run; the server-side PR needs to be deployed for the chain path to activate.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@charlesvien charlesvien self-assigned this Jul 16, 2026
@trunk-io

trunk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit b4148ad.

@charlesvien

Copy link
Copy Markdown
Member Author

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "load cloud run history from presigned lo..." | Re-trigger Greptile

Comment thread packages/core/src/cloud-task/cloud-task.ts Outdated
Comment thread apps/mobile/src/features/tasks/lib/cloudTaskStream.ts
Comment thread packages/core/src/cloud-task/cloud-task.ts
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.

1 participant