Repository navigation
Fix concurrent first-use JSON coder initialization - #46
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
odrobnik
left a comment
There was a problem hiding this comment.
No findings.
The fix in API.swift turns encoder and decoder from lazy var into stored properties that are filled in as the object is created. That removes the unsynchronized lazy first access on this @unchecked Sendable class, which is the cause issue #45 identified for the crash. The public API stays the same (same types, still settable and configurable). Subclasses could not touch these properties before super.init in either version, and no production code replaces the coders after setup.
Tests:
- The
Mirrortest reliably catches a return to lazy setup, because a lazy property starts empty. - The concurrent encoding test makes all requests wait and start together, with a 5 s timeout.
- The image test does what the issue asks: it holds three stubbed HTTP responses and releases them together on a new shared provider, for both 200 and 400 replies.
- The stub's wave and timeout handling looks correct. Old timers are ignored because each wave gets a new ID, and later tests in the serialized suite call
script, which resets the state.
One pre-existing limit remains: assigning a new coder while requests are already running is still unsynchronized. The new comment documents this ("configure or replace them before starting requests"), and it is outside this issue's scope.
👍 No findings.
Reviewed by Claude · opus
Resolves #45.
Both JSON coders now initialize before concurrent requests begin, preserving their existing settings and customization support. Added tests for simultaneous first image requests and request encoding, and all local automated checks passed on macOS. The original intermittent crash was not reproduced; live services and other platforms were not verified locally. Please check the concurrent image batch in the next build and reply with the result.