Skip to content
App
Markdown

Runtime compatibility

What the JavaScript runtime provides, what it does not, and the short list of stand-ins the platform adds.

Your server code runs in an instance-per-request JavaScript isolate: StarlingMonkey — SpiderMonkey compiled to WebAssembly — under wasmtime. A fresh instance handles each request and is discarded afterwards.

The web platform comes from the engine itself, not from a layer of ours on top of it. The platform builds that engine: StarlingMonkey's own main plus a short stack of patches, published at pilvia/starlingmonkey. A fix goes into the engine, in the shape upstream would take it, and never into your app's bundle. The app contract is the web-standard shape:

export default {
  async fetch(request, env, ctx) {
    return new Response("hello");
  },
};

env is your app's capabilities, and ctx lets work continue after the response (below).

What is available

Measured in the isolate, not from memory:

Surface Available
fetch, Request, Response, Headers yes — fetch follows redirects (see redirects)
URL, URLSearchParams yes
URL.canParse, URL.parse yes
ReadableStream, WritableStream, TransformStream yes — a ReadableStream is async-iterable (for await)
CompressionStream, DecompressionStream yes
TextEncoder, TextDecoder yes
TextEncoderStream, TextDecoderStream yes — provided by the compatibility list
FormData, Blob, File yes
atob, btoa yes
crypto.getRandomValues, crypto.randomUUID yes — while handling a request (see the module scope)
crypto.subtle partial — digest, sign, verify, encrypt, decrypt, generateKey, importKey, exportKey, deriveBits; no deriveKey and no key wrapping
AbortController, EventTarget, Event yes
setTimeout, setInterval, queueMicrotask yes
structuredClone yes
console, performance yes
performance.toJSON yes — provided by the compatibility list
reportError yes — provided by the compatibility list
navigator.userAgent yes — provided by the compatibility list; the object carries nothing else
Intl, String.prototype.normalize yes — locale data for English, Finnish and Swedish
WebAssembly no
URLPattern no
Buffer, process no
WebSocket, Worker, localStorage, caches no

Everything modern JavaScript itself defines is there — Promise, BigInt, WeakRef, FinalizationRegistry, Array.fromAsync, Object.groupBy, Iterator helpers, Error.captureStackTrace.

Anything the guest prints with console becomes a telemetry record that names your app, release and request id.

Work after the response

ctx.waitUntil(promise) keeps the instance running after your response has gone, until the promise settles. Use it for work the visitor should not wait for: an analytics beacon, a webhook, a cache refresh, a write that can land a moment later.

export default {
  async fetch(request, env, ctx) {
    ctx.waitUntil(
      fetch("https://stats.example.com/api/send", {
        method: "POST",
        body: JSON.stringify({ path: new URL(request.url).pathname }),
      }),
    );
    return new Response("hello");
  },
};

It is the shape Cloudflare Workers gives the same method, so code and frameworks written for Workers pass it on unchanged: Hono's c.executionCtx.waitUntil, and in the Astro adapter Astro.locals.ctx. waitUntil works unbound, so a framework may pass the method on by itself.

  • The time limit is the request's own. The response and the work after it share the request's budget, 10 seconds from the moment the request arrived. Whatever is still running then is stopped, and its outgoing requests are closed.
  • There is room for a limited amount of it. Work after the response holds a background slot on the server, never one that requests need. When every background slot is taken, the work is stopped at once rather than queued.
  • It is best effort. Work that is running when the platform restarts a server is lost, as a request in flight would be. Work that must happen belongs in a job.
  • It runs as the request did, with the same capabilities, the same user and the same egress grants.
  • What it prints carries the request's id, like everything else the request printed. A promise that rejects is one error record, marked as background work. Work that is stopped is one failure record that says why.
  • Call it while the request is still running, from the handler or from work already handed to it. Once the instance has nothing left to do, a call throws InvalidStateError.
  • There is no passThroughOnException. No origin stands behind your app to pass a failed request to.

An app deployed with a pilvia CLI older than 0.2.12 gets no ctx; deploy it again with a current one. Work that is neither awaited nor handed to waitUntil is dropped when the response is done, so a promise you start and forget never finishes.

Known gaps

  • Locale data for three languages. Intl and toLocaleString carry the data for English, Finnish and Swedish (en, fi, sv and their regional variants). Any other locale falls back to the root locale's neutral formats rather than failing, so de-DE formats a number, but not the way a German reader expects it. ICU's one-time initialisation is done when your release is built, so the first formatter a request uses costs well under a millisecond. A release built before 2026-10-16 pays 11–17 ms for it on every request that formats; redeploy it to get the warm-up.
  • No WebAssembly global inside the isolate. Libraries that carry a wasm build need their pure-JS build instead (es-module-lexer is the common one).
  • crypto.subtle is partial. Hashing, HMAC, ECDSA, Ed25519 and RSASSA-PKCS1-v1_5 signatures, AES-GCM, AES-CBC and AES-CTR encryption, and PBKDF2 deriveBits work, and generateKey and exportKey handle HMAC and AES keys. There is no RSA-OAEP, ECDH or HKDF, no deriveKey, wrapKey or unwrapKey, and EC, Ed25519 and RSA keys cannot be generated or exported. A release built before 2026-10-16 17:30 UTC has no AES and no generateKey or exportKey, one built before 2026-10-30 10:35 UTC has no Ed25519, and one built before 2026-11-20 07:45 UTC has no PBKDF2; redeploy it to get them.
  • An unread incoming body cannot be copied yet. new Request(request) on the request your fetch receives, before anything has read its body, crashes the instance when the copy's body is read, and so does a copy made after reading request.body. Reading the original works, as do request.clone() and new Request(url, { body: request.body, duplex: "half", … }).
  • Streaming the incoming body into fetch does not finish. An outgoing fetch whose body is request.body never settles, and the request ends in an error saying so. Read the body first (await request.arrayBuffer()) and send the bytes.
  • No MessageChannel. Libraries that schedule work through it at load, such as React's browser server renderer, fail when the release is built. Resolve their edge build instead: React's is react-dom/server.edge, which bundlers pick with the edge-light condition.
  • No AsyncContext. TC39's proposal is not in the engine yet; AsyncLocalStorage gives the same behaviour.
  • No other Node built-ins. process and the node:* modules other than node:async_hooks are absent. The Astro adapter provides Buffer for the sites it builds, because site code reaches for it casually; nothing else is polyfilled.
  • No long-lived state between requests. An instance handles one request. Module-level variables do not survive it, and neither do timers or websockets — see Releases. State belongs in data or KV.

AsyncLocalStorage

AsyncLocalStorage carries a value through everything a callback starts: across awaits, promise callbacks, setTimeout and queueMicrotask. Code deep in a request can read the request's context without it being passed down. Frameworks rely on it: TanStack Start, SvelteKit's getRequestEvent(), Hono's contextStorage(), Nitro's useEvent() and React's edge renderer.

const requestId = new AsyncLocalStorage<string>();

export default {
  fetch(request: Request) {
    return requestId.run(request.headers.get("x-pilvia-request-id") ?? "-", handle);
  },
};

async function handle() {
  await somethingSlow();
  return new Response(`request ${requestId.getStore()}`);
}

It is a global, as in Vercel's Edge Runtime, because React's edge renderer looks for it there, and node:async_hooks exports the same class. It needs no flag. Import it with pilvia 0.2.10 or later: 0.2.9 and earlier bundle a static import { AsyncLocalStorage } from "node:async_hooks" as an empty module, though the global and await import("node:async_hooks") work with them (pilvia upgrade). The engine carries the context itself: a promise callback runs in the context it was registered in, a timer in the context of the call that scheduled it, an event listener in the context of the dispatch. The methods are the subset the runtimes other than Node share: run, exit, getStore, and the static bind and snapshot. enterWith, disable and the rest of async_hooks are not there.

An instance serves one request, so a module-level variable is already request-scoped. AsyncLocalStorage still keeps apart the work one request runs in parallel, and keeps code portable to a dev server that handles many requests at once. A release built before 2026-11-20 13:24 UTC has neither the global nor the module; redeploy it.

The module scope runs when your release is built

Your bundle's top level runs once, when the platform builds the release: imports, module-level constants, and whatever a library does when it is imported. Every instance then starts from the memory it left. That is why a request does not pay for loading your code, and it is also why the top level cannot do what needs a request:

In the module scope What happens
Math.random() Works. Its values are the same in every instance of the release, as if they had been written into your code at build time. In a request every call is random again.
Date.now(), new Date() The time the release was built.
performance.now() Milliseconds since the global was made, during the build. Each request counts from its own start.
crypto.getRandomValues, crypto.randomUUID, crypto.subtle.generateKey The build fails. A key or token made there would be the same for every visitor and readable from the release, so make it in your handler, or on first use.
fetch, setTimeout, setInterval The build fails.

A build that fails this way names the call and where it was made:

Exception while evaluating top-level script
bundle.js:1:16 TypeError: crypto.randomUUID can only be used during request handling, not during initialization

The line is in the bundled bundle.js, so look for the call in the dependency that line comes from. The usual fix is to move it into a function that runs on first use.

The compatibility list

The platform keeps a short, closed list of stand-ins for standard web-platform surface the engine does not implement yet. It exists so that a gap in the engine matches the standard rather than diverging from it — and it is written down because an unwritten list would be an unbounded promise.

The list takes no new entries. Since the platform builds its own engine, a new gap is fixed in the engine instead, and an entry leaves the list in the release that ships the engine carrying it. URL.canParse and URL.parse were the first to go that way, on 2026-10-16.

Each entry qualified only if all five held:

  1. it is spec'd and stable (WHATWG / ECMA / WinterTC);
  2. it is shipped by Node, Deno, workerd and browsers;
  3. it is implementable over the engine's own primitives — no parser and no crypto of ours;
  4. it is guarded, so it becomes a no-op the day the engine ships the real thing;
  5. it names the engine change whose landing deletes it.

Entries are installed at deploy time, so every app gets them regardless of which CLI version built the release.

Entry What it is Since Leaves when
navigator.userAgent The single product token ECMA-429 § 7 asks for: Pilvia-App, no version and no comment. The object carries nothing else. 2026-09-04 StarlingMonkey grows a navigator object.
TextDecoderStream A TransformStream over the engine's own TextDecoder, decoding in streaming mode so a character split across chunks survives. encoding, fatal and ignoreBOM come off the decoder. 2026-09-04 StarlingMonkey ships the Encoding streams natively; we watch its own test expectations for that.
TextEncoderStream The same over TextEncoder, UTF-8 only, holding a lead surrogate back so a pair split across chunks encodes as one code point. 2026-09-04 StarlingMonkey ships the Encoding streams natively (the same condition).
performance.toJSON JSON.stringify(performance) answers { "timeOrigin": … } instead of {}. 2026-09-04 StarlingMonkey spec-shapes Performance.
reportError reportError(e) records the error exactly as an uncaught exception would be recorded, with its message and stack together, and the request carries on. No error event is fired on the global — see error reporting. 2026-09-04 StarlingMonkey ships reportError with the error-event machinery.

Workarounds that a framework adapter carries are not on this list and are not platform behavior: the Astro adapter's Buffer and its es-module-lexer alias are scoped to sites that adapter builds, and they are deliberately kept there rather than pushed into the runtime.

Where this stands against ECMA-429

ECMA-429, the Minimum Common Web Platform API (Ecma TC55, first edition adopted in December 2025), is the standard list of web-platform globals a server-side JavaScript runtime is required to provide. It names 78, none of them optional. Counted against the isolate, with the compatibility list applied:

Globals
Required by ECMA-429 78
The WebAssembly namespace, not available in the isolate 16
The error-event surface (onerror, onunhandledrejection, onrejectionhandled, ErrorEvent, PromiseRejectionEvent), replaced by platform error reporting as § 6 of the standard allows 5
Applicable 57
Present 53
Absent: MessageChannel, MessagePort, MessageEvent, URLPattern 4

Present means the global exists. It does not mean every corner of it conforms: on 2026-09-03, 22 of the present globals were measurably non-conformant, and the table below shows by area how far the tests pass. Both exclusions are documented divergences, which is what § 5 of the standard asks of a runtime that cannot follow it structurally. URL.canParse and URL.parse are not ECMA-429 items. They are WHATWG URL surface every other runtime ships, and the engine carries both.

Measured with web-platform-tests

web-platform-tests (WPT) is the shared conformance suite of the web platform. The engine carries its own WPT harness, which records a pass or fail for every subtest. These are its results for the engine the platform runs (release engine-20261120-0e4158f), against the WPT snapshot of 2026-10-16. In total 24,063 of 33,847 subtests pass:

Area Subtests Pass
console 50 100%
dom (events, abort) 64 100%
webidl (exceptions) 115 100%
xhr (FormData) 41 100%
encoding 11 254 99.0%
FileAPI 350 96.6%
WebCryptoAPI, without PBKDF2 7 191 95.3%
url 2 136 95.0%
html/webappapis (atob, structuredClone, timers) 526 83.1%
streams 1 371 81.0%
compression 334 71.9%
hr-time 36 66.7%
fetch 1 747 58.0%
WebCryptoAPI, PBKDF2 8 632 7.0%

How to read it:

  • Per area, never one number. encoding's table-driven tests are a third of all subtests, so a single total says more about that one area than about the runtime.
  • The numbers are the engine's own. The compatibility list's stand-ins are not counted. Each engine build runs the suite before it ships, and a build that passes fewer subtests than the one before it does not ship.
  • fetch includes cases a server runtime does not have: origin, CORS, referrer and the HTTP cache account for many of its failures (see documented divergences). That includes most of the redirect tests still failing: they expect an origin, a referrer or a browser's manual mode.
  • compression: 72 of its 94 failures are brotli, a format the suite added since the previous snapshot and the engine does not support yet. Most of the rest are shared-memory chunks that should be refused and truncated input that should raise an error.
  • WebCryptoAPI: AES encryption and decryption, and key generation for AES and HMAC, pass in full, including every test that a wrong key usage is refused. The PBKDF2 file is its own row because it is large and mostly tests what is missing: deriveBits passes 603 of its 711 subtests (the rest need ECDH keys), and its other 7,920 subtests derive keys with deriveKey, which the engine does not have yet. Most of what fails is importing EC keys (39 of 264 pass) and Ed25519 keys (26 of 72), and the operations listed under known gaps.
  • Unmeasured is not passing. The harness does not run URLPattern, messaging, the error-event family, navigator or queueMicrotask, and it skips the interface-shape tests for URL, Headers, Request and Response.

Documented divergences

Where the isolate cannot follow the standard for structural reasons, this is what it does instead.

No WebAssembly inside the isolate

Your server code itself runs as WebAssembly, and the isolate cannot compile or instantiate modules of its own. The WebAssembly namespace accounts for 16 of ECMA-429's globals. A library that ships a WebAssembly build needs its JavaScript build instead; the Astro adapter does this for es-module-lexer.

Error reporting

The isolate fires no error, unhandledrejection or rejectionhandled events on the global, and it has no onerror-style handlers. ECMA-429 § 6 allows a runtime to report these by another mechanism instead. Here that mechanism is the platform's records for the request, which carry its request id:

What happens in your code The request What is recorded
Your fetch handler throws, or the promise it returns rejects Ends with a 500 One error record with the message and the stack
You call reportError(e) Carries on The same single record
A promise rejects and nothing handles it Keeps the response your handler returned One error record per rejection, with the message and the stack
A promise you handed ctx.waitUntil rejects Already answered One error record, marked as background work
Work after the response runs past the time limit, or finds no free background slot Already answered One failure record saying which
A timer callback throws Carries on. A request left waiting on that callback ends with a 500 saying its response never settled One error record with the message and the stack
The handler runs past its time limit (10 seconds by default) Ends with a 504 A failure record naming the timeout

A release built before 2026-10-16 17:30 UTC still writes an unhandled rejection or a timer's exception as several log lines, and a throwing timer ends its request with a 500. Redeploy it to get the records above.

The 500 from a handler that throws carries the error message and stack in its body, which is what you want while developing. Catch errors you would not show a visitor, and answer with a response of your own.

fetch has no origin, CORS or referrer

There is no page, so there is no origin: the runtime adds no Origin header to outgoing requests, CORS modes are not enforced, and there is no referrer. This is the standard's own example of a structural divergence.

fetch has no HTTP cache and no keepalive

The cache and keepalive request options are not honored. Nothing is cached between requests, and an instance ends with its request and the work it handed ctx.waitUntil.

fetch is egress-governed

An app has no outbound network until its manifest grants it. The egress field names the hosts it may reach, and a request to any other host fails with a TypeError your code can catch, whatever its method or body.

fetch redirects

fetch follows redirects the way the standard says. Since there is no browser around it, three things work differently:

  • Every hop is checked against egress. A redirect to a host your manifest does not grant fails the whole fetch with a TypeError. It does not return the 3xx. Grant the redirect's target too, or pass redirect: "manual" and read Location yourself.
  • redirect: "manual" returns the redirect response itself, with its status and Location, as Node, Deno and Cloudflare Workers do. A browser would return an opaque response with status 0 instead.
  • Credentials stay with their origin. A redirect to another origin drops Authorization, Cookie and Proxy-Authorization.

As the standard says, a 301 or 302 to a POST, and a 303 to anything but GET or HEAD, continue as a GET without the body. A 307 or 308 sends the same method and body again, unless the body was a ReadableStream: a stream cannot be sent twice, so that fetch fails. There are at most 20 hops. Response.redirected and Response.url describe the last one.

A release built before 2026-10-17 00:55 UTC does not follow redirects. Its fetch returns every 3xx as it is, with Response.redirected always false. Redeploy it to get the behaviour above, and check your egress grants first.

One thread, one request

An instance handles one request on one thread. There is no Worker and no SharedArrayBuffer, and nothing in memory survives to the next request (see known gaps).

Type to search. ↑↓ to move, Enter to open, Esc to close.