Skip to content

Commit

Permalink
fix: char
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus authored and yodamaster726 committed Nov 23, 2024
1 parent d8a3a00 commit d5815a1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/adapter-postgres/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,9 @@ export class PostgresDatabaseAdapter
);

if (existingParticipant.rows.length > 0) {
console.log(`Participant with userId ${userId} already exists in room ${roomId}.`);
console.log(
`Participant with userId ${userId} already exists in room ${roomId}.`
);
return; // Exit early if the participant already exists
}

Expand All @@ -750,11 +752,13 @@ export class PostgresDatabaseAdapter
} catch (error) {
// This is to prevent duplicate participant error in case of a race condition
// Handle unique constraint violation error (code 23505)
if (error.code === '23505') {
console.warn(`Participant with userId ${userId} already exists in room ${roomId}.`); // Optionally, you can log this or handle it differently
if (error.code === "23505") {
console.warn(
`Participant with userId ${userId} already exists in room ${roomId}.`
); // Optionally, you can log this or handle it differently
} else {
// Handle other errors
console.error('Error adding participant:', error);
console.error("Error adding participant:", error);
return false;
}
} finally {
Expand Down

0 comments on commit d5815a1

Please sign in to comment.