How to properly handle errors


The documentation is not clear about how to handle errors. Although there is this here PDF.js Express Viewer Events | Documentation (, this call is never triggered as per my tests.


  • Setup the WebViewer as per the docs above
  • Subscribe to the loaderror event
  • Pass in a wrong url to the parameter initialDoc. This returns a 404 error in the network

The loaderror callback is never called.

I also tried adding a .catch() function to the Promise, but that was not called back either.

Can someone pls provide some guidance about how to handle errors? Here what I have tried:

documentViewer.addEventListener('loaderror', () => {
          debugger // never get called

And also this

        path: this.path,
        initialDoc: this.url,
        licenseKey: process.env.VUE_APP_PDFJS_KEY
      }, pdfViewer).then((instance) => {
      }).catch(() => {
        debugger // never gets called 


Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:



You can use this event:

  instance.UI.addEventListener('loaderror', () => {

(I realize this is not the best name or location for this event - I’ll talk to the team to get that fixed)