mozilla/pdf.js · error · Error
Not implemented: NetworkStream
Error message
Not implemented: NetworkStream
What it means
A build-configuration Error: in the MOZCENTRAL build (Firefox built-in viewer) the url-based NetworkStream code path is disabled and throws immediately. Mozilla ships its own network transport, so the generic PDF.js stream is intentionally unavailable. Only data or range transports work in MOZCENTRAL.
Source
Thrown at src/display/api.js:429
const workerIdPromise = worker.messageHandler.sendWithPromise(
"GetDocRequest",
docParams,
data ? [data.buffer] : null
);
let networkStream;
if (data) {
// The entire PDF was provided, no `networkStream` necessary.
} else if (rangeTransport) {
networkStream = new PDFDataTransportStream({
pdfDataRangeTransport: rangeTransport,
disableRange,
disableStream,
});
} else if (url) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Not implemented: NetworkStream");
}
const NetworkStream = getNetworkStream(url);
networkStream = new NetworkStream({
url,
httpHeaders,
withCredentials,
rangeChunkSize,
disableRange,
disableStream,
});
} else {
throw new Error(
"getDocument - expected either `data`, `range`, or `url` parameter."
);
}
return workerIdPromise.then(workerId => {View on GitHub (pinned to 5903d58d58)
Solutions
- If you need URL loading, use the GENERIC build of pdf.js instead of MOZCENTRAL.
- In MOZCENTRAL, pass data (Uint8Array) or a range transport rather than url.
- Switch your gulp/webpack target to generic / use the published pdfjs-dist package.
Example fix
// before (MOZCENTRAL build)
pdfjsLib.getDocument({ url }); // throws
// after
const data = new Uint8Array(await (await fetch(url)).arrayBuffer());
pdfjsLib.getDocument({ data }); Defensive patterns
Strategy: validation
Validate before calling
// Only pass `url` in builds that support it.
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {
const data = new Uint8Array(await (await fetch(url)).arrayBuffer());
getDocument({ data });
} else {
getDocument({ url });
} Prevention
- Use the GENERIC build when you need URL loading.
- In MOZCENTRAL, always supply data or a range transport.
- Document the build target your code assumes.
When it happens
Trigger: Calling getDocument({ url }) from code running in the MOZCENTRAL (Firefox built-in) build instead of the GENERIC build. Triggered only when PDFJSDev.test('MOZCENTRAL') is true.
Common situations: Embedding pdf.js inside Firefox/XUL and accidentally using the generic API; building with the wrong target; tests that assume GENERIC but run against a MOZCENTRAL bundle.
Related errors
- Bad begin offset: ${begin}
- Bad end offset: ${end}
- Failed to fetch file "${url}" with "${response.statusText}".
- The PDF file is empty, i.e. its size is zero bytes.
- Worker was destroyed
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/4c3071d1c3a54a64.
Report an issue: GitHub.