PaddlePaddle/PaddleOCR · error
Unsupported worker request type "${type}".
Error message
Unsupported worker request type "${type}". What it means
The worker's message dispatcher (createPaddleOCRWorkerMessageHandler) only accepts the request types 'init', 'predict', and 'dispose'. Any other type string hits the default branch and throws; the error propagates back over the worker transport as a rejected response. This indicates a version mismatch between main-thread client and worker bundle, or direct misuse of the low-level transport.
Source
Thrown at paddleocr-js/packages/core/src/pipelines/ocr/worker-entry.ts:52
return ocr.predict(sources, (payload.params || {}) as OcrRuntimeParamsInput);
}
async function handleDispose() {
await ocr?.dispose();
ocr = null;
return {};
}
return async function handleMessage(type: string, payload: Record<string, unknown>) {
switch (type) {
case "init":
return handleInit(payload);
case "predict":
return handlePredict(payload);
case "dispose":
return handleDispose();
default:
throw new Error(`Unsupported worker request type "${type}".`);
}
};
}
attachWorkerMessageHandler(createPaddleOCRWorkerMessageHandler());
View on GitHub (pinned to 2661c7c0ef)
Solutions
- Ensure the worker bundle and main-thread library come from the same paddleocr-js version (rebuild, bust caches, verify lockfile dedupe).
- Do not postMessage the OCR worker directly; go through the public API.
- If you pass a custom createWorker, make sure it loads the matching worker-entry from the same package version.
Example fix
// before (custom code poking the worker)
worker.postMessage({ type: 'warmup' }); // unsupported
// after
worker.postMessage({ type: 'init', payload: { /* options */ } }); // or just use PaddleOCR.create() Defensive patterns
Strategy: try-catch
Try / catch
try {
await ocr.predict(image);
} catch (e) {
if (e instanceof Error && e.message.includes('Unsupported worker request type')) {
// worker bundle is from a different library version: hard-reload the page / rebuild
location.reload(true);
return;
}
throw e;
} Prevention
- Serve the worker chunk and the main bundle from the same build output; fingerprint worker URLs to bust caches.
- Never postMessage the OCR worker directly — always go through the public API.
- After upgrading paddleocr-js, verify no stale worker chunk is cached (content-hashed filenames).
When it happens
Trigger: The worker bundle built from a different paddleocr-js version than the main-thread WorkerTransportClient (e.g. stale CDN cache or mixed versions in a monorepo); hand-rolled postMessage calls to the worker with an unknown type.
Common situations: Upgrading the library but the browser cached the old worker chunk; bundler misconfiguration producing worker-entry from a different package version; internal tooling posting custom messages to the OCR worker.
Related errors
- worker mode does not support a custom fetch implementation.
- worker must be a boolean or an options object.
- worker mode requires Web Worker support in this environment.
- PaddleOCR worker instance has been disposed.
- OCR worker is not initialized.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/8e62f063bf449f16.
Report an issue: GitHub.