Trying to use the pdf.js (‘pdfjs-dist’) package from npm in a worker to open a pdf file and convert the first page to an image.
When running with wrangler dev
I get an error. The error code is 10021 (error details below).
This package is listed in the ‘Works on Workers’ site (https://workers.cloudflare.com/works), but no matter how I try to import it I get an error similar to this?
Any tips on how to make this package work with a CF Worker?
`[ERROR] Error on remote worker: ParseError: A request to the Cloudflare API (/accounts/[accountid]/workers/scripts/[workername]/edge-preview) failed.
at throwFetchError (/usr/lib/node_modules/wrangler/wrangler-dist/cli.js:123033:17)
at fetchResult (/usr/lib/node_modules/wrangler/wrangler-dist/cli.js:123002:5)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async createPreviewToken (/usr/lib/node_modules/wrangler/wrangler-dist/cli.js:125029:29)
at async createWorkerPreview (/usr/lib/node_modules/wrangler/wrangler-dist/cli.js:125049:17)
at async start (/usr/lib/node_modules/wrangler/wrangler-dist/cli.js:125710:34) {
text: ‘A request to the Cloudflare API
(/accounts/[accountid]/workers/scripts/[worker-name]/edge-preview) failed.’,
notes: [
{
text: “Uncaught TypeError: Cannot read properties of undefined (reading ‘includes’)\n” +
’ at worker.js:12483:47 in get platform\n’ +
’ at worker.js:15224:42 in KeyboardManager\n’ +
’ at worker.js:15832:76 in Object.defineProperty.value\n’ +
’ at worker.js:27380:42 in w_pdfjs_require\n’ +
’ at worker.js:14774:28 in Object.defineProperty.value\n’ +
’ at worker.js:27380:42 in w_pdfjs_require\n’ +
’ at worker.js:14635:29 in Object.defineProperty.value\n’ +
’ at worker.js:27380:42 in w_pdfjs_require\n’ +
’ at worker.js:12738:41 in Object.defineProperty.value\n’ +
’ at worker.js:27380:42 in w_pdfjs_require\n’ +
’ [code: 10021]’
}
],
location: undefined,
kind: ‘error’,
code: 10021
}
`