Skip to content

Wait for in-progress ephemeral server download by progress, not a fixed deadline#1332

Merged
brianstrauch merged 2 commits into
mainfrom
fix-ephemeral-download-wait
Jun 15, 2026
Merged

Wait for in-progress ephemeral server download by progress, not a fixed deadline#1332
brianstrauch merged 2 commits into
mainfrom
fix-ephemeral-download-wait

Conversation

@brianstrauch

Copy link
Copy Markdown
Member

What

When a concurrent process is already downloading the dev/test server binary, lazy_download_exe waited a fixed 20s for the .downloading temp file to disappear and then errored:

RuntimeError: Failed starting Temporal dev server: Temp download file at
.../temporal-<version>.downloading not complete after 20 seconds.

A large binary on a slow connection — or several test workers starting servers concurrently (e.g. pytest -n auto) — legitimately takes longer than 20s, so waiters spuriously fail even though the download is alive and progressing. This was observed flaking the Python SDK's CI on 3.14, macos-arm while downloading a ~578 MB custom build.

Fix

Wait based on progress rather than a fixed deadline. The .downloading temp file is written incrementally by std::io::copy, so its mtime advances while the download is alive. We keep waiting as long as the mtime keeps advancing, and only reclaim the download (once) if it makes no progress for 60s — which indicates the downloading process died. This distinguishes "slow but alive" from "abandoned" instead of capping total wait time.

The 60s no-progress threshold replaces the previous one-shot 90s abandoned-file check; reclaim remains a single attempt (already_tried_cleaning_old) before failing loudly, so two live processes can't fight over the temp file indefinitely.

Notes

The reclaim still operates on the shared <dest>.downloading path, so 60s is deliberately well above realistic network-stall jitter: reclaiming a still-live download would unlink the temp file out from under the writer and risk publishing a partial binary. A future hardening could use a per-process unique temp name to make reclaim non-destructive and allow a shorter threshold.

… deadline

When a concurrent process is already downloading the dev/test server
binary, lazy_download_exe waited a fixed 20s for the temp file to
disappear and then errored. A large binary on a slow connection (or
several test workers starting servers at once) legitimately takes
longer, so waiters would spuriously fail with 'Temp download file not
complete after 20 seconds'.

Wait based on progress instead: keep waiting as long as the temp file's
mtime keeps advancing, and only reclaim it (once) if it stops making
progress for 60 seconds, indicating the downloading process died.
@brianstrauch
brianstrauch requested a review from a team as a code owner June 15, 2026 21:42
@brianstrauch
brianstrauch enabled auto-merge (squash) June 15, 2026 22:42
@brianstrauch
brianstrauch merged commit 681b8ba into main Jun 15, 2026
23 checks passed
@brianstrauch
brianstrauch deleted the fix-ephemeral-download-wait branch June 15, 2026 22:56
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.

2 participants