-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent UnhandledPromiseError when restoring the session #2363
Prevent UnhandledPromiseError when restoring the session #2363
Conversation
Hi, thanks for working on this! I don't exactly think this is valid, it feels like we're just silencing an actual problem in the code. It'd be nice to reproduce it and cover with a test, I could try taking a look at it. |
Hey, no problem at all. I tried writing a test for this but I was unable to reproduce it. I think it's because the try/catch will swallow any error thrown by the promise. Though I didn't think to try using The error that is being thrown comes from the use of this const https://github.com/simplabs/ember-simple-auth/blob/master/packages/ember-simple-auth/addon/internal-session.js#L69 when it's passed as the callback to the promise, which I think is a valid use of that. However, because the promise isn't directly handled by the try/catch it's still regeristing an exception. |
Here's a reproduction of what might be happening here https://ember-twiddle.com/939eb4a8aec7f6b188cfc281140191e6?openFiles=controllers.application%5C.js%2C. I think we could move forward with this PR but it'd be better to drop the setup() {
this._setupIsCalled = true;
this._setupHandlers();
return this.session.restore().catch(() => {
// If it raises an error then it means that restore didn't find any restorable state.
});
} |
8c8784f
to
d54f27e
Compare
Thanks for the detailed response and twiddle. I have updated the PR with the suggested code changes. |
I don't quite understand this tbh – there shouldn't be a difference between Admittedly it wasn't a great API choice to have the session's |
@marcoow RSVP promises seem to still emit errors to ESA used to pass a function that ran |
Hm, yeah – I think that's a reasonable argument for changing this 🤔 |
It seems like one test is failing now because the stubbed It seems it should be |
It's possible for an `UnhandledPromiseError` to raise when restoring the session. This doesn't raise to the caller of the library but does occur as a caught exception in the browser, which in turn can be picked up by error tracking code such as sentry. This fixes mainmatter#2358 which has more specific detail around the issue and how to reproduce it.
d54f27e
to
27f92e0
Compare
Ah, sorry I should have caught that before pushing that change. Test should now be passing on CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks @BobrImperator 👍 |
It's possible for an
UnhandledPromiseError
to raise in the background when restoring the session. This doesn't raise to the caller of the library but does occur as a caught exception in the browser, which in turn can be picked up by error tracking code such as sentry.This fixes #2358 which has more specific detail around the issue and how to reproduce it.