feat: add error strategy option to batch resolver#26
Merged
Conversation
Introduce an errorStrategy option ('broadcast' | 'isolate') for the batch
resolver. In 'isolate' mode the resolver returns per-item promises so each
caller settles independently, allowing failed/cancelled callers to bail
immediately instead of having errors broadcast to the whole batch.
'broadcast' remains the default and preserves existing behaviour.
Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
|
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a configurable
errorStrategyto the batch resolver so callers can choose how errors propagate across a batch. Previously, any error from the batch resolver was always broadcast to every caller in the batch, meaning a single failing item could reject unrelated callers.Changes Made
errorStrategyoption ('broadcast' | 'isolate') toBatchOptions.broadcast(default): preserves existing behaviour — a resolver error rejects all callers in the batch.isolate: the batch resolver returns per-item promises (Promise<TReturnType>[]), so each caller settles independently. Failed or cancelled callers bail immediately without affecting the rest of the batch.batchResolverto accept bothAsyncBatchFunctionand the newAsyncIsolateBatchFunctionsignature.releaseWithErrorper item and correct_activeBatchCountaccounting; synchronous throws from the resolver still broadcast.src/index.test.tscovering isolate vs broadcast behaviour.README.mddocumentation and theexamples/webappdemo (api client, config panel, defaults) to exercise the new option.Definition of Done
Additional Notes
Default behaviour is unchanged (
broadcast), so this is a backwards-compatible, additive feature.