Skip to content

Commit 7f22a99

Browse files
authored
fix(codecatalyst): activation fails in new dev environments #4811
Problem: - The extension fails to activate in new dev environments: `TypeError: Cannot read properties of undefined (reading 'scopeExpired') at pe.isScopeExpired` - The issue also cascades to existing dev environment where things like activity heartbeat fails to activate because thisDevenv on codecatalyst/activation #L80 ends up being undefined Solution: - Provide a default for connection states if they aren't found. The reason this is neccessary is on L96 in codecatalyst/auth.ts we are making a call to this.isConnectionValid(), which then checks if the scopes are expired. This happens BEFORE the scopesExpired is available in the global state for 'codecatalyst.connections' causing the issue
1 parent b90eeab commit 7f22a99

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "codecatalyst: fix extension activation in new dev environments"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "codecatalyst: fix heartbeat activity registration"
4+
}

packages/core/src/codecatalyst/auth.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,22 @@ export class CodeCatalystAuthenticationProvider {
371371
}
372372
}
373373

374-
private getState(): Record<string, ConnectionState> {
374+
private getStates(): Record<string, ConnectionState> {
375375
return this.memento.get(this.mementoKey, {} as Record<string, ConnectionState>)
376376
}
377377

378378
public getConnectionState(conn: SsoConnection): ConnectionState {
379-
return this.getState()[conn.id]
379+
return (
380+
this.getStates()[conn.id] ?? {
381+
onboarded: false,
382+
scopeExpired: false,
383+
}
384+
)
380385
}
381386

382387
private async setConnectionState(conn: SsoConnection, state: ConnectionState) {
383388
await this.memento.update(this.mementoKey, {
384-
...this.getState(),
389+
...this.getStates(),
385390
[conn.id]: state,
386391
})
387392
}

0 commit comments

Comments
 (0)