Edge Compute
Workers run JavaScript, TypeScript and WebAssembly in V8 isolates at every Cloudflare location, wired to resources through bindings. Interviewers ask what the isolate allows and costs.
on this pageshowhide
explore
- Isolates & Resource Limits6 questions
- Handlers & Execution Context5 questions
- Web-Standard Runtime APIs6 questions
- Compatibility Dates & Node APIs5 questions
- Bindings, Vars & Secrets6 questions
- Service Bindings & RPC5 questions
- Logs, Tail & Traces6 questions
- Containers Beside Workers6 questions
questions
page 2 of 2A team bumps a two-year-old Cloudflare Worker's compatibility_date to add an npm library using node:crypto and Buffer; what can break, and how do they find it?
basics
~20 sBefore the bump the library cannot load (no Node.js compatibility). After it, every runtime change dated in between also applies, such as stripped Authorization on cross-origin redirects and object-valued timers, and unenv-polyfilled methods throw when called.
In Cloudflare Workers, an npm SDK reads process.env.API_KEY and gets undefined although the secret is set; why, and what fixes it?
basics
~20 sprocess.env is filled from vars, secrets and version metadata only when Node.js compatibility is on and the compatibility date is 2025-04-01 or later (or nodejs_compat_populate_process_env is set). Otherwise it is empty, so move the date, add the flag, or pass env.API_KEY explicitly.
After wrangler deploy changed a Cloudflare Container's image, some requests still reached the old image for minutes and a few failed. Why?
basics
~20 swrangler deploy activates the new Worker first, then builds the image and rolls instances gradually, about 10% then 100%. Old instances drain up to 15 minutes after SIGTERM, so new code meets old images and cold starts.
On Cloudflare, how do you run untrusted generated code in a Dynamic Worker or a sandbox container without exposing your Worker's credentials?
basics
~20 sGive the sandbox only what its code may use: a Dynamic Worker with globalOutbound: null and scoped methods in env, or a container with Internet off and credentials added by an outbound handler, one per user.
In Cloudflare Workers, when does ctx.passThroughOnException() send a request on to the origin, and why can a proxied POST then reach the origin without its body?
basics
~20 sAfter ctx.passThroughOnException(), an unhandled exception in the Worker's code sends the request to the origin as if the Worker were absent. Bodies are streamed, so if an origin fetch() consumed the body and then threw, the fallback arrives without it.
An image-metadata Cloudflare Worker that parses large JSON uploads starts returning Error 1102 under load; how do you tell whether CPU or memory is the cause, and fix it?
basics
~20 sError 1102, Worker exceeded resource limits, covers both the CPU time limit and the 128 MB per-isolate memory limit; the outcome exceededCpu or exceededMemory says which. Cut work or raise limits.cpu_ms for CPU; stop buffering large bodies for memory.
A Cloudflare Worker signs its requests to a legacy origin with HMAC and verifies the origin's webhooks; how do you build both safely with crypto.subtle?
basics
~20 sImport the secret with crypto.subtle.importKey as a non-extractable HMAC SHA-256 key, sign a canonical string with a timestamp, and check incoming signatures with crypto.subtle.verify on the raw body, never ===. Use redirect: 'manual' so signed headers never follow a redirect.
An internal Cloudflare billing Worker must be reachable only through service bindings; which Wrangler settings keep it off the internet, and how does it know which Worker called it?
basics
~20 sSet workers_dev and preview_urls to false and configure no routes or custom domains, in the Wrangler file so every deploy keeps them. The Worker identifies callers by ctx.props, which each caller's binding sets and only those allowed to deploy the billing Worker can change.
As the lead for a team running dozens of Cloudflare Workers, what rule would you set for bumping compatibility dates, and why?
basics
~20 sBump on a regular cadence, in a change of its own that lists the flags dated in the window, tested and rolled out gradually at the new date. Set a maximum age, track every disable flag as debt, and decide the Node.js default deliberately.
In Cloudflare Workers, what does setting placement mode to smart change, and which Workers does it actually help?
basics
~20 sSmart Placement lets Cloudflare run a Worker's fetch handler near the back ends it calls, instead of nearest the visitor, when measurements show that is faster. It helps Workers making several round trips to one distant backend, not Workers answering at the edge.
How does Workers Trace Events Logpush send a Cloudflare Worker's logs to an outside destination, and what does it truncate?
basics
~20 sOn Workers Paid, an account-level Logpush job on the workers_trace_events dataset ships events from every Worker set to logpush: true: request metadata, console messages and uncaught exceptions. Logs and exceptions share 16,384 characters; past that they are truncated.
Beyond fetch(), how does a Cloudflare Worker open an outbound TCP connection with connect() and serve a WebSocket with WebSocketPair?
basics
~20 sconnect() from cloudflare:sockets opens an outbound TCP socket with readable and writable streams, optionally TLS. WebSocketPair gives two linked sockets: the Worker calls accept() on one and returns the other in a 101 Response's webSocket option.
A Cloudflare Worker's ranking recompute ran fine on an hourly Cron Trigger but fails with exceededCpu after moving to every 30 minutes; why, and what fixes it?
basics
~20 sOn Workers Paid a Cron Trigger invocation gets 15 minutes of CPU when its schedule is hourly or rarer, but only 30 seconds when it fires more often. Restore the hourly schedule, cut the work below 30 seconds, or split it.
A Cloudflare billing Worker keeps an RPC stub received as a parameter and uses it later in ctx.waitUntil(), getting 'RPC stub used after being disposed'; why, and how should stub lifetimes be managed?
basics
~20 sA parameter stub is disposed when the RPC method returns, and it calls back through the caller, so it cannot outlive the caller's request. Read the values later work needs before returning, and use dup() only inside that window.
As a platform lead on Cloudflare, how do you decide whether a workload runs in a Worker isolate, a Dynamic Worker or a Container?
basics
~20 sDefault to a Worker isolate, use a Dynamic Worker for code loaded at runtime, and choose a Container only for a named need like a native binary or over 128 MB, accepting cold starts, an image and provisioned billing.
showing 31–45 of 45