Repository navigation
Defer throwing signal work until observation - #287
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
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.
Problem
Signal(catching:)evaluates its throwing closure while constructing the signal and captures that singleResult. Consequently subscribing twice repeats the first result rather than the work, andretry(1)cannot recover from a transient failure in that closure.For example, a throwing producer that fails on its first invocation and returns
42on its second is invoked only once; observingsignal.retry(1)receives the cached failure, not42. This differs from the documented cold-signal behavior and the analogousSignal(performing:)/Signal(evaluating:)initializers.Change
Defer
Result(catching:)through the existingevaluating:initializer. Add tests for deferred/per-observation execution, failure propagation, and retry recovery, including the explicit Linux test registration.Validation
swift build -j 2passed.swift test -j 2 --filter 'SignalTests.test(Catching|ProductionAndObservation|Just|Sequence|Completed|Failed|Map|Filter|Retry$|Append$)': 12 tests passed.Published, async bridges, and this throwing-factory regression.git diff --checkpassed.Apple runtimes/Xcode, Android, and the full upstream suite (including stress tests) were not run. Existing Swift 6 concurrency warnings remain; no Swift 6 language-mode or all-platform acceptance claim.