Skip to content

Commit 3928f86

Browse files
committed
fix(matrix): avoid async event listener promises
1 parent 08b9af0 commit 3928f86

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

extensions/matrix/src/matrix/monitor/auto-join.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ export function registerMatrixAutoJoin(params: {
6969
});
7070
};
7171

72-
// Handle invites directly so both "always" and "allowlist" modes share the same path.
73-
client.on("room.invite", (roomId: string, _inviteEvent: unknown) => {
72+
const handleRoomInvite = (roomId: string, _inviteEvent: unknown) => {
7473
runInviteTask(roomId, async () => {
7574
if (autoJoin === "allowlist") {
7675
const allowedAliasRoomIds = await resolveAllowedAliasRoomIds();
@@ -92,5 +91,8 @@ export function registerMatrixAutoJoin(params: {
9291
runtime.error?.(`matrix: failed to join room ${roomId}: ${String(err)}`);
9392
}
9493
});
95-
});
94+
};
95+
96+
// Handle invites directly so both "always" and "allowlist" modes share the same path.
97+
client.on("room.invite", handleRoomInvite);
9698
}

extensions/matrix/src/matrix/monitor/events.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export function registerMatrixMonitorEvents(params: {
272272
);
273273
});
274274

275-
client.on("room.failed_decryption", (roomId: string, event: MatrixRawEvent, error: Error) => {
275+
const handleFailedDecryption = (roomId: string, event: MatrixRawEvent, error: Error) => {
276276
void runMonitorTask(
277277
`failed decryption handler room=${roomId} id=${event.event_id ?? "unknown"}`,
278278
async () => {
@@ -328,7 +328,8 @@ export function registerMatrixMonitorEvents(params: {
328328
);
329329
},
330330
);
331-
});
331+
};
332+
client.on("room.failed_decryption", handleFailedDecryption);
332333

333334
client.on("verification.summary", (summary) => {
334335
void runMonitorTask("verification summary handler", async () => {

0 commit comments

Comments
 (0)