{"record":{"id":"8e62f063bf449f16","repo":"PaddlePaddle/PaddleOCR","slug":"unsupported-worker-request-type-type","errorCode":null,"errorMessage":"Unsupported worker request type \"${type}\".","messagePattern":"Unsupported worker request type \"(.+?)\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"paddleocr-js/packages/core/src/pipelines/ocr/worker-entry.ts","lineNumber":52,"sourceCode":"    return ocr.predict(sources, (payload.params || {}) as OcrRuntimeParamsInput);\n  }\n\n  async function handleDispose() {\n    await ocr?.dispose();\n    ocr = null;\n    return {};\n  }\n\n  return async function handleMessage(type: string, payload: Record<string, unknown>) {\n    switch (type) {\n      case \"init\":\n        return handleInit(payload);\n      case \"predict\":\n        return handlePredict(payload);\n      case \"dispose\":\n        return handleDispose();\n      default:\n        throw new Error(`Unsupported worker request type \"${type}\".`);\n    }\n  };\n}\n\nattachWorkerMessageHandler(createPaddleOCRWorkerMessageHandler());\n","sourceCodeStart":34,"sourceCodeEnd":58,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr-js/packages/core/src/pipelines/ocr/worker-entry.ts#L34-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (custom code poking the worker)\nworker.postMessage({ type: 'warmup' }); // unsupported\n\n// after\nworker.postMessage({ type: 'init', payload: { /* options */ } }); // or just use PaddleOCR.create()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await ocr.predict(image);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unsupported worker request type')) {\n    // worker bundle is from a different library version: hard-reload the page / rebuild\n    location.reload(true);\n    return;\n  }\n  throw e;\n}","preventionTips":["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)."],"tags":["worker","version-mismatch","internal-api","transport"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}