Repository navigation
chore: update Container examples and container docs for enableInternet - #85
Conversation
c37fffe to
1f3da0f
Compare
CF Containers default to blocked public egress — cfeth0 only gets private addresses (10.0.0.1/24 + fd00::11), so DNS/fetch/TCP hang indefinitely. Firecracker VMs are also hermetic and don't inherit the Worker's env. - Opt in to public egress by setting ALCHEMY_CONTAINER_ENABLE_INTERNET=1 in the Worker env (or as a secret). Off by default to match CF's default. - Log a one-line hint at container start when the flag is absent, so users hitting the DNS-hang symptom can discover the fix in logs instead of debugging Firecracker networking blind. - Forward string-valued Worker env entries into ContainerStartupOptions.env via Effect.serviceOption(WorkerEnvironment) so bun can read secrets via Bun.env.XXX at runtime.
1f3da0f to
7fab0e6
Compare
| "Container starting with public egress DISABLED. Set ALCHEMY_CONTAINER_ENABLE_INTERNET=1 in the Worker env to enable internet access (cfeth0 has only private addresses by default).", | ||
| ); | ||
| } | ||
| yield* container.start({ enableInternet, env }); |
There was a problem hiding this comment.
WHy do this with an environment variable?
Let's update this function to accept those arguments so the user can just pass an arg
export const start = Effect.fnUntraced(function* <
Shape extends Container,
Req = never,
>(containerEff: Effect.Effect<Shape, never, Req | DurableObjectState>) {|
@sam-goodwin Good call — much cleaner API. Updated: Before (implicit env reading): const container = yield* Cloudflare.start(sandbox);
// secretly reads ALCHEMY_CONTAINER_ENABLE_INTERNET from WorkerEnvironmentAfter (explicit options): const container = yield* Cloudflare.start(sandbox, { enableInternet: true });Changes:
Pushed as a fixup commit on the same branch. |
1a34170 to
4018632
Compare
| options?: { | ||
| enableInternet?: boolean; | ||
| env?: Record<string, string>; | ||
| }, |
There was a problem hiding this comment.
Should we use the same type in the underlying Container .start function?
4018632 to
7145a19
Compare
|
@sam-goodwin Done, didn't saw that type, thanks! |
| // CF Containers default to BLOCKED public egress. Containers get only | ||
| // private addresses (10.0.0.1/24 + fd00::11) on cfeth0 and every DNS | ||
| // lookup / TCP connect / fetch hangs indefinitely unless enableInternet | ||
| // is explicitly set. | ||
| const enableInternet = options?.enableInternet ?? false; | ||
| if (!enableInternet) { | ||
| yield* Effect.logInfo( | ||
| "Container starting with public egress DISABLED. Pass { enableInternet: true } to enable internet access (cfeth0 has only private addresses by default).", | ||
| ); | ||
| } |
There was a problem hiding this comment.
Why are we dying here? This is not an error. It's a choice.
…iew feedback
Removes WorkerEnvironment service dependency from StartContainer.start().
Instead of implicitly reading ALCHEMY_CONTAINER_ENABLE_INTERNET and env
from the Worker environment via Effect.serviceOption, the function now
accepts an optional second argument:
Cloudflare.start(sandbox, { enableInternet: true, env: { FOO: bar } })
This makes the API explicit and avoids hidden env var coupling. Users
who need internet access or env forwarding pass it directly.
Updates all examples, docs, and test types to use the new signature.
|
Removed the log, just passes options through now. |
7145a19 to
c059b67
Compare
|
Superseded by #341 which landed the |
Co-authored-by: Cursor <[email protected]>
Problem
CF Containers default to blocked public egress. When
StartContainer.tscallscontainer.start()with no options:cfeth0only gets private addresses (10.0.0.1/24 + fd00::11) — everydns.resolve/fetch/ TCP connect hangs indefinitely (25s hard-timeout).Bun.env.XXX.Fix
ALCHEMY_CONTAINER_ENABLE_INTERNET=1in the Worker env (or as a secret). Off by default to match CF's default.ContainerStartupOptions.envviaEffect.serviceOption(WorkerEnvironment).Verification
Confirmed via a
/debug/connectivityprobe inside a bun container:ALCHEMY_CONTAINER_ENABLE_INTERNET=1: DNS resolves in <30ms, TCP connect to 1.1.1.1 completes in <20ms.Notes
Effect.logInfo(notlogWarning) since locked-down egress is a valid deployment choice.