Option to wait for all promises in `Stream.prototype.forEach` queue to finish before rejecting with a thrown error
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 54/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, node.js
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- JavaScript
- Estrelas
- 124k
- Forks
- 38k
- Merge médio
- 4d 2h
- PRs com merge (30d)
- 266
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de nodejs/node
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 69/100
Mantenedores costumam responder em até 1 dia
-
fs: document readStream.start and readStream.endTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertadoc
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
nodejs/node#67848 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
doc: document the Buffer.prototype.*Slice() methodsTalvez já em andamento @AyushCipher assumiu hoje. Abertadoc
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
nodejs/node#67847 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
`styleText` fast path bypasses `options` and `options.validateStream` validationTalvez já em andamento @GBra-4-669 assumiu há 8 dias. Abertautil
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
riscv64
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
nodejs/node#67655 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de nodejs/node
Issues semelhantes
-
bug triage needed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
[Resource]: PersephoneAbertaresource-submission validation-passed
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
hesreallyhim/awesome-claude-code#3773 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 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 statusTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia