ramandeep-singh-1983 / ngx-powerbi

TypeScript library for embedding Power BI assets (reports/dashboards/tiles) in your application. This TypeScript library is built on top of the official powerbi-client library provided by Microsoft.
MIT License
36 stars 22 forks source link

Uncaught (in promise): TypeError: Cannot read property 'postMessage' of null #48

Open aradice-truenorth opened 3 years ago

aradice-truenorth commented 3 years ago

Our application has a dashboard which makes extensive use of NgxPowerBiService.embed to render "tile" views of reports which the user can click to view the full report, a screen which makes use of NgxPowerBiComponent. This generally works very well, and we really like these components; thank you very much for developing them and making them publicly available 🥇 !

We have discovered an issue which is easy to reproduce but not in a very scientific manner: if we click around rapidly from screen to screen we encounter errors like:

Last error : Uncaught (in promise): TypeError: Cannot read property 'postMessage' of null at t.sendResponse (https://pplcmslp3web.azurewebsites.net/main-es2015.db324120385304cf3c46.js:1:404048) at https://pplcmslp3web.azurewebsites.net/main-es2015.db324120385304cf3c46.js:1:405623 at l.invoke (https://pplcmslp3web.azurewebsites.net/polyfills-es2015.18568f7b8173e068193a.js:1:7269) at Object.onInvoke (https://pplcmslp3web.azurewebsites.net/main-es2015.db324120385304cf3c46.js:1:709205) at l.invoke (https://pplcmslp3web.azurewebsites.net/polyfills-es2015.18568f7b8173e068193a.js:1:7209) at i.run (https://pplcmslp3web.azurewebsites.net/polyfills-es2015.18568f7b8173e068193a.js:1:2681) at https://pplcmslp3web.azurewebsites.net/polyfills-es2015.18568f7b8173e068193a.js:1:13613 at l.invokeTask (https://pplcmslp3web.azurewebsites.net/polyfills-es2015.18568f7b8173e068193a.js:1:7887) at Object.onInvokeTask (https://pplcmslp3web.azurewebsites.net/main-es2015.db324120385304cf3c46.js:1:709021) at l.invokeTask (https://pplcmslp3web.azurewebsites.net/polyfills-es2015.18568f7b8173e068193a.js:1:7808)

The exception is thrown by line 1 char 404048 of main.js which is (when pretty printed):

t.prototype.sendResponse = function(t, e, n) { this.addTrackingProperties(e, n), this.logMessages && (console.log(this.name + " Sending response:"), console.log(JSON.stringify(e, null, " "))), t.postMessage(e, "*") }

It looks like the error is occuring when an iframe that contained a report or a tile is no longer present when a message needs to be sent to that iframe by the container webpage. We don't want to log or display these errors and it's a bit of a pain weeding them out; is there any way that the component could be updated to swallow them silently?

bathan commented 2 years ago

Having the exact same issue. Some defensive code around those lines would be greatly apprecciated.

KotanaSai21 commented 1 year ago

This Issue is with the windows-post-message-proxy and it has been fixed with the latest beta release windows-post-message-proxy-npm-0.2.7

Try installing the latest version powerbi-client: 2.22.4 Refer powerbi-client-npm

LMK if the issue still exists.