You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
watcher.ts: Replaces if (!map.has(key)) map.set(key, []); map.get(key)!.push(...) with const list = map.get(key) ?? []; list.push(...); map.set(key, list). Eliminates two non-null assertions.
market-utils.ts: Replaces market.yes!.label = market.title (mutation + non-null assertion) with market.yes = { ...market.yes, label: market.title } (spread-copy). Same for market.no. Also tightens the guard from market.title && yesLabel === 'yes' to market.title && market.yes && yesLabel === 'yes'.
throttler.ts: Adds a maxQueueDepth config option (default 1000). When the queue exceeds this depth, the oldest entry is dropped (shifted and resolved). This prevents unbounded memory growth if producers enqueue faster than the token bucket drains.
Blast Radius
watcher.ts: Internal resolver-push pattern, no behavioral change.
market-utils.ts: addBinaryOutcomes is called from 15+ normalizers across all exchanges. The spread-copy is semantically different: the old code mutated the outcome object's label in-place, meaning market.outcomes[0].label would also change (since market.yes points to the same object). The new code creates a new outcome object for market.yes/market.no, so market.outcomes[0] retains its original label while market.yes gets the new one. This is a behavioral change.
throttler.ts: Used for rate limiting across exchanges. The queue-drop behavior changes how back-pressure works.
Findings
market-utils.ts behavioral change is significant. After this PR, market.yes.label and market.outcomes[0].label can diverge when the title-promotion logic fires. Previously they were the same object reference. Consumers that read market.outcomes[0].label instead of market.yes.label will see different values. This could affect matching, display, or serialization. Needs verification that no downstream code relies on outcomes-array labels being updated by addBinaryOutcomes.
throttler.ts queue-drop silently resolves the dropped request. The oldest queued request's resolve() is called, meaning the caller proceeds as if throttled successfully. This could cause a brief rate-limit burst if the caller then immediately fires a request. Consider whether reject() with a descriptive error would be safer, so callers know they were dropped rather than approved.
watcher.ts is clean. The ?? [] pattern is equivalent and avoids the assertion.
Semver Impact
minor -- the maxQueueDepth config addition is additive, but the market-utils.ts behavioral change around outcome object identity could be breaking for consumers that rely on reference equality between market.yes and market.outcomes[0].
Risk
Medium-High. The market-utils.ts change silently alters object identity semantics in a function used by every exchange normalizer. Needs integration testing to confirm no downstream breakage.
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
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.
Fixes #269
Fixes #296
Fixes #329