skip to content

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 pageshow

explore

questions

page 2 of 2

A 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?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Before 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.

open as a page

In Cloudflare Workers, an npm SDK reads process.env.API_KEY and gets undefined although the secret is set; why, and what fixes it?

level: seniorimportance: should knowfreq 30%

basics

~20 s

process.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.

open as a page

After wrangler deploy changed a Cloudflare Container's image, some requests still reached the old image for minutes and a few failed. Why?

level: seniorimportance: should knowfreq 22%

basics

~20 s

wrangler 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.

open as a page

On Cloudflare, how do you run untrusted generated code in a Dynamic Worker or a sandbox container without exposing your Worker's credentials?

level: seniorimportance: should knowfreq 24%

basics

~20 s

Give 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.

open as a page

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?

level: seniorimportance: should knowfreq 30%

basics

~20 s

After 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.

open as a page

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?

level: seniorimportance: should knowfreq 50%

basics

~20 s

Error 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.

open as a page

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?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Import 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.

open as a page

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?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Set 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.

open as a page

As the lead for a team running dozens of Cloudflare Workers, what rule would you set for bumping compatibility dates, and why?

level: principalimportance: should knowfreq 24%

basics

~20 s

Bump 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.

open as a page

In Cloudflare Workers, what does setting placement mode to smart change, and which Workers does it actually help?

level: middleimportance: nice to knowfreq 25%

basics

~20 s

Smart 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.

open as a page

How does Workers Trace Events Logpush send a Cloudflare Worker's logs to an outside destination, and what does it truncate?

level: middleimportance: nice to knowfreq 20%

basics

~20 s

On 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.

open as a page

Beyond fetch(), how does a Cloudflare Worker open an outbound TCP connection with connect() and serve a WebSocket with WebSocketPair?

level: middleimportance: nice to knowfreq 22%

basics

~20 s

connect() 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.

open as a page

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?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

On 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.

open as a page

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?

level: seniorimportance: nice to knowfreq 18%

basics

~20 s

A 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.

open as a page

As a platform lead on Cloudflare, how do you decide whether a workload runs in a Worker isolate, a Dynamic Worker or a Container?

level: principalimportance: nice to knowfreq 18%

basics

~20 s

Default 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.

open as a page

showing 31–45 of 45