stackdriver-errors-js icon indicating copy to clipboard operation
stackdriver-errors-js copied to clipboard

Cannot set property onunhandledrejection of [object Object] which has only a getter

Open patelnav opened this issue 6 years ago • 6 comments

This may have birthed from Issue#35.

I'm seeing logs with the following error:

TypeError: Cannot set property onunhandledrejection of [object Object] which has only a getter
    at onunhandledrejection (../node_modules/stackdriver-errors-js/stackdriver-errors.js:91:0)
    at window.addEventListener (index.js:133:15)

This is happening on my starting the ErrorReporter. index.js:133 is line 3:

window.addEventListener('DOMContentLoaded', function () {
  var errorHandler = new StackdriverErrorReporter();
  errorHandler.start({
    targetUrl: '<my_url>',
  });
})

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

patelnav avatar Jan 04 '19 07:01 patelnav

Thanks for the report. Do you confirm you are using the module at HEAD?

steren avatar Jan 04 '19 18:01 steren

I just installed from npm, so it's the 0.5.0 release.

Should I wait for a minor release or just start using HEAD?

patelnav avatar Jan 04 '19 19:01 patelnav

I did a bit of digging. It seems I was rejecting a promise with a string, which caused this section to generate an error to report. So the stack starts at this point.

Unfortunately the stack traces cross async-boundaries on these Promises, so they not particularly useful.

Unless you guys can figure out how to get the full stacktrace, perhaps it would be more useful to not have a StackTrace rather than a partial & internal one.

patelnav avatar Jan 05 '19 12:01 patelnav

Version 0.5.0 is supposed to work.

Would you be able to provide a minimal sample (e.g. on codepen) that reproduces the issue?

steren avatar Jan 22 '19 02:01 steren

hmmm. was trying this, ran into another issue. The CDN ( https://cdn.jsdelivr.net/npm/[email protected]/dist/ ) doesn't even have a window.onunhandledrejection

A messup on publishing to CDN?

patelnav avatar Jan 22 '19 05:01 patelnav

Can't seem to repro this right now ( https://codepen.io/navpatel/pen/LqYZKq ). Will try to dig up how this happened on my end and figure it out.

patelnav avatar Jan 22 '19 05:01 patelnav