Skip to content

Commit

Permalink
Refactor Session.setup to handle promise errors
Browse files Browse the repository at this point in the history
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 #2358 which has more specific detail around the issue and how to reproduce it.
  • Loading branch information
swelham committed Mar 14, 2022
1 parent 0e4f57d commit d54f27e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/ember-simple-auth/addon/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,12 @@ export default Service.extend(Evented, {
@method setup
@public
*/
async setup() {
setup() {
this._setupIsCalled = true;
try {
this._setupHandlers();
await this.session.restore();
} catch (error) {
this._setupHandlers();

return this.session.restore().catch(() => {
// If it raises an error then it means that restore didn't find any restorable state.
}
});
},
});

0 comments on commit d54f27e

Please sign in to comment.