Reputation: 305
I'm using PDF.JS for loading pdfs. While loading pdf, i'm getting this error,
ERROR Error: Unknown action from worker: undefined
at Worker.MessageHandler._onComObjOnMessage (pdf.js:6846)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:28122)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:503)
at invokeTask (zone.js:1671)
at Worker.globalZoneAwareCallback (zone.js:1697)
undefined comes from actionHandler
In pdf.js:6846
const action = this.actionHandler[data.action];
if (!action) {
throw new Error(`Unknown action from worker: ${data.action}`);
}
I took reference from here, https://github.com/jzgoda/ng-pdfjs/blob/master/src/app/app.component.ts
I'm using the worker from https://github.com/jzgoda/ng-pdfjs/blob/master/src/assets/pdf.worker.min.js
pdfjsLib.GlobalWorkerOptions.workerSrc = 'assets/js/pdf.worker.min.js';
Upvotes: 4
Views: 3961
Reputation: 101
i got this same error before:
ERROR Error: Unknown action from worker: undefined
and my code is
var pdfjsLib = require("pdfjs-dist/build/pdf.js");
pdfjsLib.GlobalWorkerOptions.workerSrc = 'assets/js/pdf.worker.min.js';
The code does not a problem. My work as upgrading the pdf.js to latest version. During my own operation error, i copied the different version of pdf.js and pdf.worker.min.js, then came out above error. After i prepared a matching version between pdf.js and pdf.worker.min.js. Then this error disappears. This is for your reference.
Upvotes: 7