matrix-appservice-irc icon indicating copy to clipboard operation
matrix-appservice-irc copied to clipboard

Return promises inside Promise.all map

Open f0x52 opened this issue 1 year ago • 2 comments

Currently this code doesn't return anything inside the map() callback, resulting in an array with undefined elements, and Promise.all() immediately returning. https://github.com/matrix-org/matrix-appservice-irc/blob/b0fb7387ab22465804377dc4f5e81d6fa7a5ddb8/src/bridge/MatrixHandler.ts#L766-L768

Fixed it by adding a return but could also be styled as

await Promise.all(Object.keys(members).map((u) => this.membershipQueue.leave(event.room_id, u, req)));`

Caught this when I added my standard eslint config to my fork, might be useful to include the array-callback-return rule here too.

f0x52 avatar Jan 06 '24 01:01 f0x52

The eslint rule also catches this line, though there it doesn't really matter as the return value isn't used anyways (but forEach would be more semantically correct) https://github.com/matrix-org/matrix-appservice-irc/blob/b0fb7387ab22465804377dc4f5e81d6fa7a5ddb8/src/bridge/RoomAccessSyncer.ts#L459-L461

f0x52 avatar Jan 06 '24 01:01 f0x52

Signed-off-by: f0x [email protected]

f0x52 avatar Apr 08 '24 21:04 f0x52

I think this is okay to merge, even without the changelog (it's a very internal change afaic).

tadzik avatar Sep 18 '24 14:09 tadzik