Skip to content

Instantly share code, notes, and snippets.

View gwilczynski's full-sized avatar

Grzegorz Wilczyński gwilczynski

View GitHub Profile

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

@gwilczynski
gwilczynski / audit.yml
Last active March 17, 2024 21:58 — forked from LukeMathWalker/audit.yml
GitHub Actions - Rust setup
name: Security audit
on:
schedule:
- cron: '0 0 * * *'
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit: