✨ Add tab pool architecture to storybook SDK#192
Conversation
This comment has been minimized.
This comment has been minimized.
Code Review - Tab Pool ArchitectureThis is a solid architectural improvement that addresses real CI timeout issues. The implementation is well-structured and follows the codebase's functional patterns. StrengthsArchitecture & Design
Code Quality
|
Areas for Improvement1. Missing Test Coverage - HIGH PRIORITYIssue: The new pool.js and tasks.js files (552 lines total) have zero test coverage. Impact: Core functionality like tab recycling, retry logic, and pool draining is untested. This is risky for CI-critical code. Recommendation: Add test files:
Critical test cases needed:
Location references:
|
2. Potential Race Condition in Pool ReleaseIssue: In pool.js:100-148, the release() function has a potential race when recycling tabs. Location: clients/storybook/src/pool.js:117-132 Scenario:
Fix: Notify waiting workers when recycling fails - in the catch block around line 129-132 that does totalTabs--, also notify waiting workers by resolving with null if any are waiting. 3. Silent Reset FailuresIssue: resetTab() swallows all errors, which could mask serious issues. Location: clients/storybook/src/pool.js:79-91 Concern: If resetTab() fails repeatedly, tabs accumulate stale state but continue being used. This could cause flaky screenshots. Recommendation: Add debug logging for reset failures to provide visibility when troubleshooting. |
4. Retry Logic Only Covers TimeoutsIssue: The retry logic only handles timeout-like errors but not other transient failures. Location: clients/storybook/src/tasks.js:237-241 Current detection: Only retries timeout, Timeout, Target closed, and Protocol error Potential gaps:
Consider: Expanding retry logic or making it configurable to handle more transient error types. 5. Hard-Coded Pool Recycle ThresholdIssue: DEFAULT_RECYCLE_AFTER = 10 is not configurable. Location: clients/storybook/src/pool.js:11 Concern: Large Storybooks with heavy stories might need more aggressive recycling (every 5 uses). Small ones might tolerate 20 uses. Recommendation: Consider exposing this via configuration for advanced users who need to tune performance. |
6. Browser Args Now Always Use CI FlagsIssue: Removed the isCI() check, so CI-optimized flags now run in local dev too. Location: clients/storybook/src/browser.js:63-70 Impact: Local dev now uses --disable-gpu, --disable-web-security, etc. This is probably fine (even good for consistency), but worth documenting. Recommendation: Add a comment explaining this intentional change for consistency between local and CI environments. 7. Progress Output Race Condition (Minor)Issue: The output coordinator queues errors but could drop them if progress updates stop. Location: clients/storybook/src/tasks.js:180-186 Scenario: If the last few tasks error out but no more progress updates come, errors sit in pendingErrors until flush(). The flush() call at tasks.js:346 handles this correctly, but the flow is subtle. Recommendation: Document the flush requirement more clearly in the comment. |
Minor Suggestions1. ETA Calculation Edge CaseLocation: clients/storybook/src/tasks.js:303 When config.concurrency = 1 and remaining = 1, you still divide by concurrency. This is mathematically correct but worth a comment explaining the parallelism calculation. 2. Magic Number for ETA SamplesLocation: clients/storybook/src/tasks.js:223 Consider extracting 5 and 0.1 as named constants with explanation of why these values balance early feedback vs accuracy. 3. Formatting ConsistencyThe test file changes show mostly import reordering and formatting fixes. These are good hygiene but make the diff larger. Consider whether these should be in a separate formatting commit. |
Security ReviewNo security concerns identified. The changes:
Test Plan ValidationThe PR's test plan says:
Recommendation:
|
Overall AssessmentVerdict: Approve with changes This PR solves a real problem (CI timeouts) with a well-architected solution. The code quality is high and follows repository patterns well. The main blocker is missing test coverage for critical new code. Before merging:
Estimated test additions: ~200-300 lines of test code to match the 552 lines of new functionality. Great work on the architectural improvement! The tab pooling pattern is exactly what this codebase needs for reliable CI operation. |
Port the robust browser management from static-site SDK: - Add pool.js with tab reuse, recycling after 10 uses, state reset - Add tasks.js with retry logic on timeout/crash, progress tracking - Simplify browser.js to match static-site patterns - Update index.js to use pool-based architecture Fixes timeout issues in CI by: - Automatically retrying failed screenshots with fresh tabs - Recycling tabs to prevent memory leaks - Using CI-optimized browser flags
8867cd2 to
cbaa6d2
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Vizzly - Visual Test ResultsCLI Reporter - 6 changes need review
Changes needing review (6)filter-failed-only · Firefox · 1920×1080 · 1.3% diff bulk-accept-dialog · Firefox · 1920×1080 · 10.3% diff viewer-zoomed-100 · Firefox · 1920×1080 · 0.4% diff filter-failed-only · Firefox · 375×704 · 14.2% diff bulk-accept-dialog · Firefox · 375×667 · 208.9% diff fullscreen-viewer · Firefox · 375×667 · 162.1% diff CLI TUI - Processing...Build in progress...
|
1 similar comment
Vizzly - Visual Test ResultsCLI Reporter - 6 changes need review
Changes needing review (6)filter-failed-only · Firefox · 1920×1080 · 1.3% diff bulk-accept-dialog · Firefox · 1920×1080 · 10.3% diff viewer-zoomed-100 · Firefox · 1920×1080 · 0.4% diff filter-failed-only · Firefox · 375×704 · 14.2% diff bulk-accept-dialog · Firefox · 375×667 · 208.9% diff fullscreen-viewer · Firefox · 375×667 · 162.1% diff CLI TUI - Processing...Build in progress...
|
Vizzly - Visual Test ResultsCLI Reporter - 6 changes need review
Changes needing review (6)filter-failed-only · Firefox · 1920×1080 · 1.3% diff bulk-accept-dialog · Firefox · 1920×1080 · 10.3% diff viewer-zoomed-100 · Firefox · 1920×1080 · 0.4% diff filter-failed-only · Firefox · 375×704 · 14.2% diff bulk-accept-dialog · Firefox · 375×667 · 208.9% diff fullscreen-viewer · Firefox · 375×667 · 162.1% diff CLI TUI - 1 change needs review
|







Summary
Port the robust browser management from static-site SDK to fix timeout issues in CI:
Also fixes the
services.get is not a functionbug - the dist wasn't rebuilt after the source was fixed.Test plan
VIZZLY_TOKENset