A small program asks the browser what it supports, why "I don't know" is not "no", and the TypeScript that keeps the two apart.
A user reports that the video editor does not work in their browser. Someone on the team says Safari does not support WebCodecs — the browser's built-in API for decoding and encoding video — and the bug is closed as "not our problem". A week later the same build works in Safari on another machine, and nobody knows why. The guess was not a measurement; it was a memory of a browser from three versions ago.
The browser does not expose a brand, it exposes features. It can answer, at runtime, whether it has a codec, a background thread, a storage API, a compression stream, a GPU. The answer has four values, not two: present, absent, blocked, and unknown. Treating the last one as absent is how a product refuses a browser it could have supported, and how a support team promises a feature it never checked.
This article runs the program that shows the difference. It takes three machines that all look "not present" to a true/false check and prints three different verdicts — and the reason each one has. Everything below is in the repository, and the output is from the run.
Repo: github.com/edgarmilvus/zero-backend · GitHub: @edgarmilvus · Ebook: Zero Backend
A browser is not a brand
A user-agent string — the text a browser sends to say who it is — is a claim, not a fact. It is sent by the browser, it can be shortened, spoofed or frozen by a compatibility mode, and it says nothing about whether a particular API exists on the device in front of you. A probe asks the object: does window.VideoDecoder exist? Does navigator.storage.getDirectory exist? Can a Worker — a background thread the page can start — be constructed? Those questions have answers the browser cannot fake without also breaking the feature.
The book's chapter 2 makes the point concrete: a sniffer looks at the user agent and says Safari has no WebCodecs; the same Safari, probed, has it. A spoofed Chrome says the opposite. The string and the feature disagree, and the feature is the one that runs.
Four answers, not two
The probe returns a verdict for each capability:
- present — the API exists and its prerequisites are met;
- absent — the API does not exist on this device;
-
blocked — the API exists, but something it needs is missing. Background threads are the common case:
SharedArrayBuffer(a block of memory the page and its workers can read and write) exists, but the page is not cross-origin isolated — it does not send the two HTTP headers, Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy (COOP and COEP), that tell the browser to isolate it — so the browser withholds the buffer. The fix is the headers, not a different browser; - unknown — nobody asked yet. This is not a failure of the device; it is a gap in the probe.
"Blocked" is the one teams miss. A boolean canUseThreads() returns false for both "this browser has no threads" and "this page did not send the headers", and those are different bugs with different fixes. A verdict with a reason is what lets support say "send COOP and COEP" instead of "use Chrome".
Run the three machines
The program builds three capability objects: one where WebCodecs was never probed, one where it was probed and is absent, and one where threads exist but the page is not isolated. Then it probes all three and prints the verdicts. Run it in Node (the program that runs JavaScript outside the browser), not in a browser, on purpose: the probe is the same code in both, and Node's small profile is the honest answer for Node. In a browser, the same program prints a different table.
git clone https://github.com/edgarmilvus/zero-backend.git
cd zero-backend
node chapters/chapter02/files/05_unknown_is_not_false.ts
/**
* Example 5 - unknown is not false.
*
* node chapters/chapter02/files/05_unknown_is_not_false.ts
*
* Three machines that are all "not present" to a boolean probe, and three different
* verdicts. The difference decides whether a chapter degrades, refuses, or has to be
* verified again on this device before anybody promises anything.
*/
import { probe, type Capabilities } from "./probe.ts";
import { formatVerdict } from "./probe.ts";
import { detectCapabilities } from "./detect.ts";
const base = detectCapabilities();
const neverProbed: Capabilities = {
...base,
present: { ...base.present, webcodecs: undefined },
};
const lookedAndMissing: Capabilities = {
...base,
present: { ...base.present, webcodecs: false },
};
const existsButForbidden: Capabilities = {
...base,
sharedArrayBuffer: true,
crossOriginIsolated: false,
present: { ...base.present, workers: true },
};
export function main(): number {
const rows: [string, Capabilities][] = [
["never probed", neverProbed],
["probed, absent", lookedAndMissing],
["present, blocked", existsButForbidden],
];
for (const [label, caps] of rows) {
const profile = probe(caps);
const webcodecs = profile.reports.find((report) => report.id === "webcodecs");
const threads = profile.reports.find((report) => report.id === "threads");
console.log(label.padEnd(18), `webcodecs ${formatVerdict(webcodecs?.verdict ?? "unknown")}`);
console.log("".padEnd(18), `threads ${formatVerdict(threads?.verdict ?? "unknown")} ${threads?.why ?? ""}`);
console.log("".padEnd(18), `tier ${profile.tier}`);
console.log("");
}
const unknown = probe(neverProbed);
const absent = probe(lookedAndMissing);
console.log(
`same boolean, different answer: tier ${unknown.tier} against tier ${absent.tier}`,
);
return 0;
}
if (import.meta.main) {
process.exit(main());
}
never probed webcodecs unknown
threads blocked SharedArrayBuffer exists, but the page is not cross-origin isolated: send COOP and COEP
tier 0
probed, absent webcodecs no
threads blocked SharedArrayBuffer exists, but the page is not cross-origin isolated: send COOP and COEP
tier 0
present, blocked webcodecs no
threads blocked SharedArrayBuffer exists, but the page is not cross-origin isolated: send COOP and COEP
tier 0
same boolean, different answer: tier 0 against tier 0
Read the output
The first row is the one that matters: unknown. Nobody asked whether this machine has WebCodecs, so the honest answer is not "no". A UI that turns that row into "unsupported" has invented a fact.
The second row is absent: the probe asked, the API is not there, and the answer is no. That is a fact about the device, and a fallback is the right response.
The third row is blocked: the thread API exists, SharedArrayBuffer exists, but the page is not cross-origin isolated, so the browser will not hand the buffer over. The reason names the fix. This is the verdict a boolean throws away.
The tier is a cumulative level: the twelve capabilities are grouped into three rungs, and you reach rung 2 only if rung 1 is complete. A gap on the first rung keeps the whole machine at 0, however many later capabilities exist.
The last line is the joke the program makes at its own expense: both machines reach tier 0, because this run is in Node and Node lacks other first-rung capabilities. The tier did not move; the verdict did. And the verdict is what decides whether you can promise a feature, degrade it, or have to probe again on the user's device. A tier is a summary; the rows are the evidence.
Why "unknown" must not become "no"
Support teams work with three states, not two: works, does not work, and not checked. If the third collapses into the second, every unverified browser becomes unsupported, and every customer on it becomes a refund. The probe gives the third state a name, so the product can say "we have not verified this device" and ask for a profile instead of guessing.
The same rule applies inside the code. A capability that was never probed must not raise the tier; a capability whose dependency is missing is blocked, not absent; and a profile without a probe is refused rather than filled with defaults. Chapter 2's harness — the program that runs the chapter's checks — asserts all three, because the bug is easy to introduce and invisible in a screenshot.
The profile is a file
The probe writes a profile: the engine and version, the date, whether the page is cross-origin isolated, and twelve capabilities with their verdicts. The profile is JSON, so it can be attached to a support ticket, compared between two machines, and read before a feature is attempted. The book's chapter 2 also builds a matrix from the profile: given these verdicts, which chapters of the book can run here, and which are blocked, and why.
That is the difference between a support conversation and a guess: the profile is the same file the product used, not a screenshot of a settings page.
What a probe does not prove
It proves that an API exists, not that it is fast. A codec can decode in hardware or fall back to a slow path; a worker can keep a frame at 16 ms or freeze the page for 300. The book separates the two questions on purpose: chapter 2 asks what the browser can do, and later chapters measure what it does — a transcode in the tab, a model in a worker, a gigabyte in bounded memory.
A probe also does not replace a test on the user's device. It tells you what to try; the measurement tells you whether it was worth it.
a
Where the probe leads — and what it saves
The probe is not a technicality. It is the first line of the invoice: it decides whether a job can run on the device, and the device is the tier with no egress — the bytes a server sends over the network, which every cloud provider bills by the gigabyte. A product that skips it makes one of two expensive mistakes. It builds a server path for every user and pays 79.3% of a media bill in egress for jobs a phone could do. Or it promises a client feature to a device that cannot run it, and pays in support, refunds and lost trust.
The profile turns "can we move this?" into a number. Twelve capabilities, each present, absent, blocked or unknown. Present means the saving applies to this user. Blocked names a fix — two headers, not a new server. Unknown means the device has not been checked, and the honest answer is "not yet", not "no". That last distinction is economic too: a browser marked unsupported without a probe is a customer you refused for free.
Then the savings themselves, measured in the chapters that follow: a gigabyte hashed in 76 MB instead of 1,023; a million rows at 2.4 MB instead of 23.3; a model loaded in a worker with a 16.7 ms frame instead of 215; the whole notes app in 14,376 bytes. None of those numbers is a promise for every device. The probe is how you know which of them apply to the user in front of you, and the measurement is how you know what the move costs on the devices where it does.
The verdicts gate the rest of the book: WebCodecs and threads decide whether the video chapters can run, IndexedDB (a database inside the browser) and the origin private file system — a folder a page can write to without a file picker — decide the storage chapters, workers decide the model chapter. Each of those chapters starts by asking the probe, not the user agent.
Repo: github.com/edgarmilvus/zero-backend — MIT, twenty chapters, every claim checked against a record
GitHub: @edgarmilvus — the other books and repositories
Ebook: Zero Backend — the prose around the code
Top comments (0)