Skip to content

fix: match NOT_LISTENING_ERROR against local-dev runtime message#230

Open
juanibiapina wants to merge 2 commits into
cloudflare:mainfrom
juanibiapina:fix/not-listening-error-string
Open

fix: match NOT_LISTENING_ERROR against local-dev runtime message#230
juanibiapina wants to merge 2 commits into
cloudflare:mainfrom
juanibiapina:fix/not-listening-error-string

Conversation

@juanibiapina

@juanibiapina juanibiapina commented Jun 22, 2026

Copy link
Copy Markdown

Problem

The isNotListeningError helper uses .toLowerCase().includes(matchingString) to detect the error. In production the runtime returns:

The container is not listening in the TCP address 10.0.0.1:8080

In local dev (wrangler dev) the runtime returns:

container is not listening on TCP address ...

The current constant 'the container is not listening' is not a substring of the local-dev variant (which omits the leading "the"), so isNotListeningError never returns true. The readiness loop in waitForPort / startAndWaitForPorts retries indefinitely and the Durable Object blocks forever.

Fix

Shorten the constant from 'the container is not listening' to 'container is not listening'. This is a substring of both variants, so the .includes() check works in both environments.

Environment

macOS 26.5.1 (arm64, Apple Silicon)
Node:      v24.15.0
pnpm:      10.21.0
wrangler:  4.103.0
@cloudflare/containers: 0.3.7
Docker:    29.4.0 (via OrbStack 2.2.1, kernel 7.0.11-orbstack)

Not sure whether the Docker runtime (OrbStack vs Docker Desktop) matters for this particular issue. Mentioning it in case it is relevant.

The isNotListeningError helper uses .includes() to detect the error.
In production the runtime returns 'The container is not listening in
the TCP address ...', but in local dev (wrangler dev) it returns
'container is not listening ...' without the leading 'the'. The
current constant 'the container is not listening' is not a substring
of the local-dev variant, so the readiness loop never recognises the
error and retries indefinitely.

Shorten the constant to 'container is not listening' so it matches
both variants.
@juanibiapina juanibiapina requested a review from a team as a code owner June 22, 2026 09:19
Add a unit test that mocks the local-dev error message (without the
leading 'the') and asserts doStartContainer returns immediately
instead of retrying. The test counts fetch calls: 2 with the fix
(recognised on first try), 3 without (falls through to retry).
prisis added a commit to anolilab/lunora that referenced this pull request Jun 29, 2026
Move @cloudflare/containers to a devDependency and let packem inline its
source into dist, so the fixes we carry as a pnpm patch actually ship to
consumers. A published runtime dep would resolve to the pristine,
still-buggy 0.3.7 on a consumer machine; bundling the patched source
bakes the fixes into what we publish.

The patch backports two upstream PRs:
- cloudflare/containers#191: alarm-scheduler spinloop under concurrent
  callers (alarm fires sub-second, saturates the DO event loop, cancels
  WebSocket upgrades) — re-arm a single storage alarm, idempotent
  scheduleNextAlarm.
- cloudflare/containers#230: NOT_LISTENING_ERROR did not match the
  wrangler-dev message, hanging the local readiness loop.

packem externalizes only the cloudflare:workers built-in; everything
else inlines. @lunora/container/do is now self-contained (consumers no
longer need @cloudflare/containers installed) and the package has zero
runtime dependencies.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxJinV1B4eyMBJnXEEDSfS
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