Skip to content

Commit f2d4171

Browse files
committed
HDSProfile: graceful fallback when connection lacks profile/ access
load() now catches errors when fetching profile events, so app-scoped connections (e.g. doctor-dashboard) don't crash on hookToConnection().
1 parent 3ea506d commit f2d4171

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

ts/settings/HDSProfile.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,18 @@ async function load (): Promise<void> {
164164
_values = { ...DEFAULTS };
165165
_cache = {};
166166

167-
const events: any[] = await _connection.apiOne(
168-
'events.get',
169-
{ streams: ['profile'], limit: 100 },
170-
'events'
171-
);
167+
let events: any[];
168+
try {
169+
events = await _connection.apiOne(
170+
'events.get',
171+
{ streams: ['profile'], limit: 100 },
172+
'events'
173+
);
174+
} catch {
175+
// Connection may not have access to profile/ streams (e.g. app-scoped permission)
176+
_hooked = true;
177+
return;
178+
}
172179

173180
for (const event of events) {
174181
const key = matchField(event);

0 commit comments

Comments
 (0)