Warning: Setting up fake worker. .... cannot read properties of undefined (reading 'workermessagehandler')

Which product are you using?

PDF.js Express Version

Warning: Setting up fake worker. … cannot read properties of undefined (reading ‘workermessagehandler’)

Detailed description of issue
I am trying to develop a viewer using ur PDFJSExpress package on a React/NextJS app, and everything is ok except that from time to time I am getting a popup message on the viewer saying that “Warning: Setting up fake worker. … cannot read properties of undefined (reading ‘workermessagehandler’)”

I have searched Hi and low for this … would appreciate any help on the matter please
Thanks in advance

Expected behaviour
{Provide a screenshot or description of the expected behaviour}

Does your issue happen with every document, or just one?
Random documents, sometime will work some times will show popup

Link to document
{Provide a link to the document in question if possible}

Code snippet
`const WebViewer = (await import(‘@pdftron/pdfjs-express-viewer’)).default;

            path: '/pdfjs/lib',
            licenseKey: 'NIV4p9fOcUkApaoyG7kA', //TODO: Move to env
            // initialDoc: '/downloads/MARC-Data-Consent-Notification-v2-is215-a.pdf',
        }, viewer.current).then((inst: any) => {
            instance.current = inst;

            if(type === 'FILE') {
                inst.UI.loadDocument(data, { filename: 'MARC-Data-Consent-Notification-v2-is215-a.pdf' });

            if(type === 'BASE64') {
                inst.UI.loadDocument(base64ToBlob(data), { filename: 'myfile.pdf' });

            // you can disable annotations

            // customize the UI
            // inst.UI.setTheme({ primary: 'blue', secondary: 'white' });

            // now you can access APIs through the WebViewer instance
            const { Core } = inst;

            // adding an event listener for when a document is loaded
            Core.documentViewer.addEventListener('documentLoaded', () => {
                console.log('PDF documentViewer loaded');

            Core.documentViewer.addEventListener('loaderror', () => {
                console.log('PDF documentViewer error');

            // adding an event listener for when the page number has changed
            Core.documentViewer.addEventListener('pageNumberUpdated', (pageNumber: number) => {
                console.log(`Page number is: ${pageNumber}`);


Hello Alilishan,

What version of PDF.js are you using? Please try using the latest one version 8.7.4.

Are you hosting your files on any other domain? If possible, could you please provide a sample project where the issue is reproducible? You can host the repo on GitHub if that’s easier.

Thank you.

Best Regards,
Darian Chen