Closed Eblax closed 6 years ago
If you're not running in a V8-based environment like node then maybe using something like https://www.npmjs.com/package/error-polyfill globally in your app might resolve all of this at once in all modules you require in addition.
I'm hesitant to put a workaround in for an environment I cannot run CI with and therefore ensure everything works as intended.
Fair enough, I'll check that out.
Let me know how it goes, if it comes down to just this and you don't hit any other issues, I'll merge the PR.
Seems like other modules required by this one (e.g. got) have the same issue, so feel free to disregard the pull request. The error-polyfill had some issues on its own ('Unexpected frame by generating stack.') so I'll stick with my workaround for the time being. Thanks for the quick reply!
👌
FWIW this seems to be the polyfill you should use to actually get stack traces.
if (!Error.captureStackTrace) {
Error.captureStackTrace = function captureStackTrace (error) {
var container = new Error()
Object.defineProperty(error, 'stack', {
configurable: true,
get: function getStack () {
var stack = container.stack
// Replace property with value for faster future accesses.
Object.defineProperty(this, 'stack', {
configurable: true,
value: stack,
writable: true
})
return stack
},
set: function setStack (stack) {
Object.defineProperty(error, 'stack', {
configurable: true,
value: stack,
writable: true
})
}
})
}
}
Thanks, that seems to work like a charm (after replacing defineProperty with Object.defineProperty) I'll use that to make my workaround a bit less workaroundy :)
I'm using this module in an Ionic mobile project. This works fine in Chrome and on Android, but it would not run correctly on iPhone and Firefox. I tracked the issue down to a missing check if
Error.captureStackTrace
is defined inlib\open_id_connect_error.js
, which would causeIssuer.discover
to stop running.For a quick workaround I added
if(Error && !Error['captureStackTrace']) { Error['captureStackTrace'] = function() {} }
before the first call toIssuer.discover
.I see most other node modules in my project do an
if (Error.captureStackTrace)
before running it so maybe that could be an idea?