Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return promises inside Promise.all map #1787

Closed
wants to merge 3 commits into from

Conversation

f0x52
Copy link
Contributor

@f0x52 f0x52 commented Jan 6, 2024

Currently this code doesn't return anything inside the map() callback, resulting in an array with undefined elements, and Promise.all() immediately returning.

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

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 f0x52 requested a review from a team as a code owner January 6, 2024 01:47
@f0x52
Copy link
Contributor Author

f0x52 commented Jan 6, 2024

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)

matrixRooms.map((room) => {
this.ircBridge.getStore().setModeForRoom(room.getId(), "s", enabled);
});

Copy link
Contributor

@Half-Shot Half-Shot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but needs a signoff before I can merge it.

@f0x52
Copy link
Contributor Author

f0x52 commented Apr 8, 2024

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

@tadzik
Copy link
Contributor

tadzik commented Sep 18, 2024

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

@f0x52 f0x52 closed this by deleting the head repository Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants