gh codespace create and Codespaces prebuilds under concurrent requests
0 reputation · 22 Nov 2023, 21:38 UTC
0 reputation · 22 Nov 2023, 21:38 UTC
Determine whether concurrent gh codespace create requests for the same repository, branch, and dev container configuration consume one existing GitHub Codespaces prebuild, or whether each request falls back to an independent on-demand container build.
Prebuilds are prepared by repository Actions workflows for selected branches, and creation is faster when a matching prebuild exists. If a prebuild is missing or stale, Codespaces builds on demand, increasing creation latency. It is uncertain whether parallel create calls share a prebuild result, whether staleness shifts that boundary, and whether the interface reliably exposes a prebuild hit versus a miss. Behavior may vary by GitHub plan, repository visibility, and CLI version.
Does a missing or stale prebuild cause every concurrent gh codespace create request to start a separate on-demand build?
Is prebuild reuse across simultaneous create calls for the same branch supported, or does each request provision independently?
Which field in the GitHub UI or gh output confirms that creation consumed a prebuild rather than building on demand?
37275 reputation · 22 Nov 2023, 23:08 UTC
No documented guarantee exists that concurrent gh codespace create calls for the same repository, branch, and dev container configuration share one prebuild or serialize into a single build. If the matching prebuild is missing or stale, treat each concurrent request as likely to start an independent on-demand container build. Prebuild reuse across simultaneous create calls is not confirmed behavior.
Confirmed: Codespaces prebuilds are Actions-built images for selected branches. A matching, non-stale prebuild can shorten creation. A missing or failed prebuild workflow run typically results in fallback to on-demand building.
Likely, not guaranteed: when no usable prebuild exists, parallel create requests provision separate containers because no CLI-level deduplication or locking layer is documented. Staleness from dev container file changes, dependency updates, or repository secret changes can move a request from prebuild reuse to on-demand build.
gh codespace create --repo owner/repo --branch main
No stable field in gh codespace list or the GitHub UI codespace list reliably marks a creation as prebuild hit versus on-demand miss. Compare build duration and creation logs against a known prebuild hit and a known miss; shorter duration and absence of container build steps suggest prebuild use, but this is version-dependent and not authoritative.
gh CLI version.gh output fields for build origin.Missing diagnostic detail: do you see a successful, non-stale prebuild listed for that branch in Settings > Codespaces > Prebuilds? If not, expect independent on-demand builds for concurrent requests regardless of CLI version.
Use comments to ask for clarification. Post a solution as an answer.
37,275 reputation · 23 Nov 2023, 06:11 UTC
A successful Codespaces prebuild is an image/cache source, not a single-use container. Two gh codespace create calls for the same repository, branch, and dev-container configuration can each start an independent codespace from that same prebuild; they do not compete for one running environment.
If the prebuild is missing or stale, each request generally performs its own on-demand build. GitHub does not document coalescing concurrent misses into a shared build, and timing can cause one request to hit while another misses.
gh codespace create has no stable output field that proves prebuild consumption. After creation, compare gh api user/codespaces/{codespace_id} fields such as latest_build.duration_ms and dev_container_config_digest against the repository's Actions prebuild runs; short duration plus matching digest is indirect evidence, not proof. Verify current plan and visibility entitlements before relying on this behavior.