fix: await GetClientID() and add safe navigation for error handling

Two bugs fixed:

1. Missing await for GetClientID() in leaveSessionRest
   - jamClient.GetClientID() returns a Promise
   - Was passed unresolved to deleteParticipant(), causing
     DELETE /api/participants/[object Promise] 404 error
   - Now properly awaited before use

2. Unsafe property access on error object
   - error.controlled_location accessed without null check
   - Changed to error?.controlled_location (optional chaining)
   - Prevents "Cannot read properties of undefined" error

These issues manifested when using MacBook Pro built-in mic/speakers
instead of Scarlet audio interface, likely due to different
initialization timing or missing audio profile causing error paths.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-02-02 08:42:32 +05:30
parent c4cc80e967
commit 970bbe3eb4
2 changed files with 4 additions and 2 deletions

View File

@ -367,7 +367,9 @@ const JKSessionScreen = () => {
} catch (error) {
logger.error("User profile is not appropriate for session:", error);
if (!error.controlled_location) {
if (!error?.controlled_location) {
// Handle error without controlled_location
// Session leave will be triggered by outer catch block
}
}
} catch (error) {

View File

@ -440,7 +440,7 @@ export default function useSessionModel(app, server, sessionScreen) {
// Leave session REST call (from useSessionLeave)
const leaveSessionRest = useCallback(async () => {
const clientId = jamClient.GetClientID();
const clientId = await jamClient.GetClientID();
if (!clientId) return;
try {