matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
460 stars 149 forks source link

Return promises inside Promise.all map #1787

Open f0x52 opened 6 months ago

f0x52 commented 6 months ago

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 commented 6 months ago

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 commented 2 months ago

Signed-off-by: f0x github@cthu.lu