Repository navigation
Description
Summary
On Windows, a workerd process aborts with
*** std::terminate() called with no exception
when a worker in that process declares a tailConsumer whose target lives in a second workerd process (reached via an external service over a loopback socket), and that second process dies abruptly (SIGKILL / taskkill /T /F).
There is no exception, no JS stack, and the abort happens on a non-main thread. The process dies immediately rather than surfacing a delivery error for the tail event.
Version / platform
- workerd
1.20260731.1 compatibility_date2025-05-01- Windows only. Not reproducible on macOS or Linux across many hundreds of cycles.
- Reached via Miniflare (
workers-sdk), which is what wires the cross-process tail consumer up; see "How it's configured" below.
Signature
*** std::terminate() called with no exception
stack: 7ffd4a141249 7ff692d863a5 7ffd4a15baff 7ffd4a143a9c 7ffd4a15ae8c 7ffd4a142ce1 7ffd4a15b8f7
7ffd583a700e 7ffd5824e592 7ffd4a15b3d5 7ffd4a141c1f 7ffd4a142dd7 7ffd4a15b8f7 7ffd583a6f8e
7ffd58252326 7ffd5824a960 7ffd555a75f9 7ffd4a1455a8 7ff69441045f 7ff692d85f63 7ff694415512
7ff69441c416 7ff694415a6b 7ff69441c416 7ff694412fbb 7ff692d71e77 7ff69624219e 7ffd56a1e8d6
7ffd582cc53b
The stack is byte-identical across every occurrence once ASLR base addresses are normalised, so this is a single deterministic path. We could not symbolize it — $LLVM_SYMBOLIZER is unset on the CI runners and the release binary is stripped — which is the main reason we're filing rather than proposing a fix.
How it's configured
Two independent workerd processes, each with its own config, cross-referencing each other:
- Process 1 hosts worker
A, which hasassetsconfigured (so its incoming requests are fronted by an asset/router worker pair and its user worker is reached over RPC). - Process 2 hosts worker
B, which declarestailConsumers: [A].
B's tail consumer is not a local service — it's an external service that proxies over a loopback socket into process 1.
When process 1 dies abruptly, process 2 aborts with the signature above.
Notably the abort also happens when both sessions are completely idle — no request ever traverses the binding. So this is not triggered by an in-flight tail event from live traffic; merely having the consumer configured and the peer die is enough.
Reproduction rate and discriminators
Measured on Windows CI, isolating one variable at a time (each "arm" is repeated kill/restart cycles against an otherwise identical setup):
| Arm | Crash rate |
|---|---|
B tails A, where A has assets |
4/4 (and 12/13 in an earlier round) |
B has no tail consumer |
0/4 (16 cycles) |
B tails a peer without assets |
0/4 (18 cycles) |
B tails A (assets), service binding between them removed |
4/4 |
So:
- The tail consumer edge is necessary.
- The peer having assets configured is necessary.
- A service binding between the two is irrelevant — removing it does not help, and the crash occurs with no traffic at all.
- Killing an assets-enabled worker that is not anyone's tail consumer: 0/6 (28 cycles). Killing a non-assets worker that is bound as a service: 0/6 (23 cycles).
What we ruled out
- Traffic over the binding — idle sessions still crash.
- Process restarts by themselves — 0/3 with 7–10 restarts and no peer present.
- Registry/config churn with no live peer — 0/3.
- Peer count, port contention, start order — 0/41 combined.
- CPU starvation — 0/3 with a live peer under load.
- Reporting tail-forward failures at the JS layer (workers-sdk#14993) — 8/8 still crashed, i.e. the abort is below the JS-visible layer.
- Bypassing the extra RPC hop that assets introduces for tail delivery — 4/4 and 3/4 still crashed. This is worth emphasising because it's the obvious explanation for why
assetsis a discriminator, and it appears to be wrong. We don't have a mechanism that explains theassetsdependency.
Impact
This is the direct cause of a persistent CI flake in workers-sdk (multi-session local dev tests), where abruptly terminating one vite dev / wrangler dev session kills a sibling session's runtime. For users running several local dev sessions with tail consumers pointed at each other, stopping one session can take down another.
The workers-sdk side already surfaces the crash report and restarts the runtime (workers-sdk#14989), so it's recoverable — but the abort itself looks like it should be a delivery error rather than a process kill.
What would help
Even without a fix: if a maintainer recognises this stack shape, or can point at where tail-event delivery to an unreachable external service could reach std::terminate on a non-main thread, we can narrow it from our side. We're happy to run instrumented builds on Windows CI — that's where we have a reliable ~100% repro.
Activity
[fixtures] Re-enable the dev-registry tests on Windows
[fixtures] Re-enable the dev-registry tests on Windows
petebacondarwin commentedon Aug 6, 2026
Dug into this. Two of the premises in the report are wrong in ways that matter, and the chain now
closes end to end. Summary first, evidence below.
The abort is on the main thread, not a worker thread. The stack trace is structurally incapable of
identifying the cause — only the discarded
kj::Exceptionmessage can. The most likely origin iskj::FdConnectionReceiver::accept()on Windows, which has three unguarded throw sites that the Uniximplementation explicitly defends against.
Correction 1: it's the main thread
Every Windows thread bottoms out at
BaseThreadInitThunk/RtlUserThreadStart, including the mainone — the main thread runs
RtlUserThreadStart→BaseThreadInitThunk→ CRT startup →main.Normalising the reported stack against module bases (the two captured runs differ by a constant EXE
slide of
0x4D30000, which confirms the module grouping):RtlUserThreadStartBaseThreadInitThunk__scrt_common_main_seh)main()kj::runMainAndExit+kj::MainBuilderdispatch (…c416twice = subcommand recursion, not re-entrancy)CliMain::serve()(withserveImplinlined)_CxxThrowExceptionRaiseException__CxxFrameHandler4,FindHandler+0x442from frame 19 — same functionterminateCorrection 2: the stack cannot identify the bug
There is exactly one frame between
serve()(19) and_CxxThrowException(17). If the exceptionhad originated in the event loop there would be a dozen kj promise-continuation frames there.
There aren't.
Frame 18 is
Promise::wait()re-throwing an exception that was captured asynchronously.kj::_::waitImpl(kj/async.c++) runs the loop in a nested scope and returns before the throw, sothe originating stack is already gone. The origin
file:lineonly exists in thekj::Exceptionpayload — which is precisely what's being discarded.
So: no amount of symbolication of this trace will help. That's why it's been a dead end.
The chain
The diagnostic black hole
kj::runMainAndExitalready wraps the main function and would print the full exception(
kj/main.c++:219→*** Uncaught exception ***\n<kj::Exception>) and exit non-zero. BothCliMain::serveImpl(workerd.c++:1406) andCliMain::serve(workerd.c++:1465) are declarednoexcept, which pre-empts that and turns it intostd::terminate()instead.git log -Lsuggests this is accidental:noexceptwas paired with[[noreturn]]in e14287e,both were dropped in a2d5d18 for
KJ_CLEAN_SHUTDOWN, and ebb5b48 restorednoexceptalone.Server::taskFailedalso doesn't log:This has been fatal-for-any-exception since the initial import (a265d5c), when the only tasks were
listen loops that genuinely shouldn't fail.
Why it must be an accept loop
Server::taskshas exactly five add-sites:server.c++:6136,:6301,:6497,:6860,:6883.None is outbound, so an outbound failure cannot be fatal.
:6136(per-HTTP-connection) is explicitlytry/caught with the comment "do not consider exceptions from a specific connection to be fatal".
:6497only runs during drain. That leaves the accept loops:HttpListener::run()—server.c++:6086TcpListener::run()—server.c++:6294DebugPortListener::run()—server.c++:6358, viacapnp::TwoPartyServer::listen()None has any error handling around accept. Read-side failures are contained
(
TwoPartyServer::taskFailedlogs), so it is the accept path by elimination.The Windows accept path
kj/async-io-win32.c++,FdConnectionReceiver::accept():KJ_FAIL_WIN32("AcceptEx()", ioResult.errorCode)AcceptExcompletes →ERROR_NETNAME_DELETED(64),ERROR_CONNECTION_ABORTED(1236),ERROR_SEM_TIMEOUT(121)setsockopt(SO_UPDATE_ACCEPT_CONTEXT)viaKJ_WINSOCKgetpeername()viaKJ_WINSOCKWSAENOTCONNon a reset socketThe Unix implementation defends against exactly this race in three separate places
(
kj/async-io-unix.c++)::1398-1414— retries onEINTR/ENETDOWN/EPROTO/EHOSTDOWN/EHOSTUNREACH/ENETUNREACH/ECONNABORTED/ETIMEDOUT, with the comment "accept() may report an error if the acceptedconnection is already broken. In this case, we really ought to just ignore it and keep waiting."
:1342— retries whenaccept()returnsaddrlen == 0("The socket is already dead and shouldbe discarded")
:1363-1375—KJ_SYSCALL_HANDLE_ERRORSaroundTCP_NODELAY, tolerating "EINVAL … for socketsthat are already dead (due to a race with RST)"
Windows has none of it, and calls
getpeername()where Unix doesn't need to (accept()returns theaddress atomically). Upstream capnproto
mainhas the same gap.Independent corroboration that this error family is live in this exact setup —
workers-sdkalreadycarries two workarounds naming it by number:
packages/miniflare/src/index.ts— dev-registry-proxy was given its own socket because "theinternal Cap'n Proto service-to-service forwarding from the entry worker can break (WSARecv error
64)"
packages/miniflare/src/workers/browser-rendering/binding.worker.ts— "kj/async-io-win32.c++WSARecv (Support locales Chromium disables #64) — the connection went away mid-read"
Why the tail edge is necessary and the service binding isn't
ExternalServiceProxy's constructor(
packages/miniflare/src/workers/core/dev-registry-proxy.worker.ts) callsDEV_REGISTRY_DEBUG_PORT.connect()twice — once inresolve(), once forcore:entry. Merelyconstructing the entrypoint opens two TCP connections to the peer's debug port. A service binding
only connects when a request actually traverses it. That matches the measured arms exactly: tail edge
necessary, binding irrelevant, idle sessions still affected.
Both processes accept from each other
fixtures/dev-registry/wrangler.*.jsonc— the tail edges are mutual pairs:Per
packages/miniflare/src/shared/DEV_REGISTRY.md, every session gets--debug-port=127.0.0.1:Nand reaches peers by connecting to their debug port. With mutual tail edges both processes are
simultaneously client and server on each other's debug ports, so an abrupt kill RSTs connections
sitting in the survivor's accept queue. This closes the gap left by the deduction above.
Still unexplained: the
assetsdiscriminatorThe only concrete difference is
defaultEntrypointService—core:user:<name>for a plain workerversus
assets:rpc-proxy:<name>for an assets worker (DEV_REGISTRY.md). Tail forwarding usesdefaultEntrypointService. Given that bypassing the extra hop still reproduced (4/4 and 3/4), myreading is that this widens the race window rather than being causal. I could not do better than
that, and it remains the weakest part of the analysis.
Ruled out
Server::tasks, so cannot be fatal.TwoPartyServer::taskFailedand theper-connection try/catch at
server.c++:6136.parseAddress— moot,debugPortAddressis a literal127.0.0.1:N.Fix in progress
Two parts, one PR:
Diagnostics — so this class of failure can never be silent again:
Server::taskFailedlogs the exception before rejectingfatalFulfillernoexceptfromCliMain::serveImplandCliMain::servesokj::runMainAndExitreportsthe exception and exits non-zero
Accept resilience — workerd-side, no upstream dependency:
is logged and retried with backoff; consecutive failures escalate to fatal, so a listener that
is genuinely broken still fails the server rather than spinning.
No error classification for now.
kj::Exceptioncarries no OS error code, andtypeOfWin32Erroronly maps
WSAE*codes — soERROR_NETNAME_DELETED(64) and friends arrive asFAILED, notDISCONNECTED. Filtering onDISCONNECTEDwould miss the most likely site. The retry bound, notthe classification, is what preserves "a broken listener is fatal".
Bind/listen failures remain fatal — they throw before any accept, and Miniflare depends on
EADDRINUSEkilling the process.Follow-ups, deferred until the diagnostics confirm the exception on Windows CI:
kj/async-io-win32.c++(mirror the Unix tolerance at all three sites), and/ormap
ERROR_NETNAME_DELETED/ERROR_CONNECTION_ABORTED/ERROR_SEM_TIMEOUTtoException::Type::DISCONNECTEDintypeOfWin32Error. Once that lands, the workerd-side tolerancecan be narrowed to
DISCONNECTEDwith backoff kept purely as spin protection.workers-sdk:ExternalServiceProxyopens two debug-port TCP connections per construction, i.e.per tail dispatch. Caching per
debugPortAddress, as the DO proxy already does, would cut thechurn.
Note
This investigation was carried out by an AI agent: opencode, claude-opus-5.
Retry failed accept() rather than shutting the server down
[fixtures] Re-enable the dev-registry tests on Windows
[fixtures] Re-enable the dev-registry tests on Windows