Cannot read property ‘sendWithPromise’ of null error

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [X] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

I’ve got an error log from one of customers.

TypeError: Cannot read property 'sendWithPromise' of null
  at e.getPage(/main.fcbd366b59adeaccde73.js:1:2580545)
  at e.getPage(/main.fcbd366b59adeaccde73.js:1:2562311)
  at e.renderPage(/main.fcbd366b59adeaccde73.js:1:2100087)
  at e.updateSize(/main.fcbd366b59adeaccde73.js:1:2098625)
  at ? (/main.fcbd366b59adeaccde73.js:1:2095964)
  at i(/main.fcbd366b59adeaccde73.js:1:2155073)
  at t.invokeTask(/polyfills.6daafc40a5cb42269e22.js:1:8745)
  at Object.onInvokeTask(/main.fcbd366b59adeaccde73.js:1:313689)
  at t.invokeTask(/polyfills.6daafc40a5cb42269e22.js:1:8666)
  at e.runTask(/polyfills.6daafc40a5cb42269e22.js:1:3929)
  at e.invokeTask(/polyfills.6daafc40a5cb42269e22.js:1:9835)
  at invoke(/polyfills.6daafc40a5cb42269e22.js:1:9726)
  at n.args.(anonymous function)(/polyfills.6daafc40a5cb42269e22.js:1:25027)

I couldn’t reproduce the issue but here are my thoughts.

It seems that this error appears after a user tries to change page index in the PDF preview.
The piece of code where the issue happenes looks like this

var l=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(function(e){if(n.destroyed)throw new Error("Transport destroyed");var l=new M(t,e,n,n._params.pdfBug);

Since the issue happens after renderPage and getPage my guess is that the source of issue is the not initialized _pdf variable which is at 388 line of this file
https://github.com/VadimDez/ng2-pdf-viewer/blob/master/src/app/pdf-viewer/pdf-viewer.component.ts

Could it be that I’m right and that additional check like this

if (!this._pdf) {
      return;
    }

could fix the issue?
Thanks

1 possible answer(s) on “Cannot read property ‘sendWithPromise’ of null error

  1. This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.