Repository navigation
fix(Cloudflare/Container): await monitor() Promise instead of discarding it - #74
Merged
sam-goodwin merged 1 commit intoApr 20, 2026
Merged
Conversation
…ing it state.container.monitor() returns Promise<void> that resolves when the container process exits.\nWrapping it in Effect.sync() creates a synchronous effect that discards the\nreturn value, so the Promise is never awaited. The monitor fiber completes\ninstantly (logging 'monitor exited' at the same ms as 'started') and never\ndetects container process death.\n\nThis causes container.running to stay stale (true) when the process dies,\nensureRunning skips restart, and port.fetch hangs on a dead process.\n\nFix: Use Effect.promise() to properly await the monitor Promise.\n\nNote: start() remains Effect.sync() since Container.start() returns void\nper @cloudflare/workers-types (synchronous). Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
sam-goodwin
added a commit
that referenced
this pull request
Jul 28, 2026
Review feedback from #963 (john-royal): replace the hand-rolled ephemeral-workerd gateways with the runtime's platform proxy (cloudflare-tools#88, extracted from #74). - D1: withLocalD1Query opens a proxy hosting a raw `d1` service binding and POSTs the full D1 HTTP protocol through the proxy's fetch passthrough — multi-statement migrations/imports keep working, minus the bespoke gateway worker. - KV/R2: the REST-API emulation gateways are gone entirely. For `dev:` ids the *Local layers now build the same native-binding clients the *Binding variants use (makeReadKVClient / makeRead / …) over per-operation proxied bindings; real ids keep the HTTP clients. A shared dispatchByMode builds the per-call dispatching client from the lazily-resolved id. R2 rich objects (R2ObjectBody bodies, metadata, writeHttpMetadata) ride the proxy's new "r2-object" encoding. - LocalGateway.ts shrinks to the shared runtime layer, gatewayName, and dispatchByMode; the REST-emulation scaffolding (withLocalGateway, rebaseHttpClient) is deleted. Co-authored-by: Cursor <[email protected]>
sam-goodwin
added a commit
that referenced
this pull request
Aug 4, 2026
Co-Authored-By: Claude Fable 5 <[email protected]>
DavidJFelix
pushed a commit
to DavidJFelix/alchemy-effect
that referenced
this pull request
Aug 7, 2026
…chemy-run#74) Co-authored-by: Sisyphus <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
state.container.monitor()returnsPromise<void>that resolves when the container process exits. Wrapping it inEffect.sync()creates a synchronous effect that discards the return value, so the Promise is never awaited.The monitor fiber completes instantly (logging "monitor exited" at the same ms as "started") and never detects container process death. This causes
container.runningto stay stale (true) when the process dies,ensureRunningskips restart, andport.fetchhangs on a dead process.Fix
Use
Effect.promise()to properly await the monitor Promise:Note:
start()remainsEffect.sync()sinceContainer.start()returnsvoidper@cloudflare/workers-types(synchronous).Testing
Deployed to Cloudflare Workers with a DeviceContainer (Bun runtime). After the fix:
port.fetch()no longer hangs indefinitely on dead processes