Skip to content

Add non-waking container fetch method#212

Open
ghostwriternr wants to merge 1 commit into
cloudflare:mainfrom
ghostwriternr:non-waking-container-forward
Open

Add non-waking container fetch method#212
ghostwriternr wants to merge 1 commit into
cloudflare:mainfrom
ghostwriternr:non-waking-container-forward

Conversation

@ghostwriternr
Copy link
Copy Markdown
Member

@ghostwriternr ghostwriternr commented May 18, 2026

Some request paths need to proxy traffic only when a container is already available. The Sandbox SDK preview URL path is one example: stale preview URL requests should be rejected without waking or starting a stopped container. Other passive traffic, health-adjacent routing, or authorization-gated proxy paths have the same requirement.

Today the Container class exposes fetch() and containerFetch() for forwarding, but both start the container and wait for ports before proxying the request. That makes callers choose between accidentally waking containers or duplicating the base class's forwarding logic.

This adds fetchIfRunning() as a non-waking forwarding primitive. It forwards only when the container is already running and marked healthy, and otherwise returns without starting, probing, or waiting for ports. containerFetch() now shares the same internal forwarding helper after its existing start/wait behavior succeeds, so HTTP, WebSocket, activity timeout, and inflight request accounting stay consistent across both paths.

Expose fetchIfRunning so callers can proxy to an already healthy
container without using wake-capable fetch paths. This lets consumers
serve passive traffic without accidentally starting stopped containers.
@ghostwriternr ghostwriternr requested a review from a team as a code owner May 18, 2026 11:58
@ghostwriternr ghostwriternr changed the title Add fetchIfRunning to Container Add non-waking container fetch method May 18, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/containers@212

commit: 34c61b5

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