Option to wait for all promises in `Stream.prototype.forEach` queue to finish before rejecting with a thrown error
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 54/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, node.js
Rechercherichtung
Start by reading the implementation and tests for Readable.prototype.forEach, especially how concurrency and promise rejections are handled. Add an option that waits for already started callbacks to settle and combines additional failures in an AggregateError. Done means tests cover the option with concurrent callbacks that resolve and reject, and verify that forEach settles only after those callbacks finish.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What is the problem this feature will solve?
Preventing side effects from running after Stream.prototype.forEach has returned when concurrency is greater than 1 and a promise has rejected (which currently results in forEach immediately rejecting, leaving already started promises running).
In the following example up to 63 existing calls to processAsset may be running if one call throws an exception, resulting in observable side effects.
export async function generateBrotliArtifacts(
manifests: Manifest[],
appRootDir: AbsolutePath,
): Promise<void> {
async function processAsset(assetPath: RelativePath) {
const chunkBuffer = await fs.readFile(AbsolutePath.join(appRootDir, assetPath));
// Generate plain brotli artifact for non-batched requests
const brotliPath = AbsolutePath.join(appRootDir, assetPath + BROTLI_EXT);
const compressedBrotliData = await compress(chunkBuffer);
await fs.writeFile(brotliPath, compressedBrotliData);
}
await Readable.from(getPrecompressedAssetPaths(manifests))
.forEach(processAsset, { concurrency: 64 });
}
This is problematic when used in combination with import('node:fs/promises').mkdtempDisposable (disposal occurs while writes can still occur), or with tests where multiple tests cases reuse a common directly (or re-assign with a before callback).
What is the feature you are proposing to solve the problem?
A new option to wait for already started promises to be completed. If additional promise rejections or thrown errors occur, they are bundled up into a single AggregateError (so no error is silently discarded).
A potential further optimisation would be triggering the AbortSignal given to callees (wrapping one provided to forEach with AbortSignal.any()) and discarding expected errors (functions properly implementing the abortable API contract reject with the provided reason). However I consider this to be a separate nice-to-have request that deserves it's own separate option.
What alternatives have you considered?
- Catching errors and triggering a provided
AbortSignal,forEachwill still return early. - Observing errors (catch and re-throw) and triggering a provided
AbortSignal. Can reduce but not eliminate side effects.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 124k
- Forks
- 38k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 266
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nodejs/node
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
Maintainer antworten meist innerhalb von 1 Tag
-
fs: document readStream.start and readStream.endEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offendoc
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
nodejs/node#67848 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
doc: document the Buffer.prototype.*Slice() methodsEvtl. vergeben @AyushCipher hat das heute übernommen. Offendoc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
nodejs/node#67847 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
`styleText` fast path bypasses `options` and `options.validateStream` validationEvtl. vergeben @GBra-4-669 hat das vor 8 Tagen übernommen. Offenutil
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
riscv64
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
nodejs/node#67655 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
bug triage needed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
[Resource]: PersephoneOffenresource-submission validation-passed
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
hesreallyhim/awesome-claude-code#3773 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the statusEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag