Skip to content

Commit 7863606

Browse files
committed
services/session: Add debug logs
The `<PrivilegedAction>` tests are currently flaky and it is unclear exactly why. These debug statement might help us in figuring out the root cause of the flakiness.
1 parent 8509205 commit 7863606

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/services/session.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { debug } from '@ember/debug';
12
import Service, { inject as service } from '@ember/service';
23
import { tracked } from '@glimmer/tracking';
34

@@ -179,16 +180,21 @@ export default class SessionService extends Service {
179180
});
180181

181182
loadUserTask = dropTask(async () => {
182-
if (!this.isLoggedIn) return {};
183+
if (!this.isLoggedIn) {
184+
debug('User is not logged in, skipping user load');
185+
return {};
186+
}
183187

184188
let response;
185189
try {
186190
response = await ajax('/api/v1/me');
187-
} catch {
191+
} catch (error) {
192+
debug(`Failed to load user: ${error}`);
188193
return {};
189194
}
190195

191196
let currentUser = this.store.push(this.store.normalize('user', response.user));
197+
debug(`User found: ${currentUser.login}`);
192198
let ownedCrates = response.owned_crates.map(c => this.store.push(this.store.normalize('owned-crate', c)));
193199

194200
let { id } = currentUser;

0 commit comments

Comments
 (0)