fix(web): cancel superseded compression work and bound the ingest fan-out - #39
Closed
PunGrumpy wants to merge 6 commits into
Closed
fix(web): cancel superseded compression work and bound the ingest fan-out#39PunGrumpy wants to merge 6 commits into
PunGrumpy wants to merge 6 commits into
Conversation
Each compress run gets its own AbortController; invalidateJob aborts the prior run's controller before bumping the generation, and removeJob/clearAll abort any run still in flight for jobs no longer in the queue.
Dropping many large files fanned out every createImageBitmap decode at once; ingestFiles now runs through the same pool the compress queue uses, so at most MAX_CONCURRENT_JOBS decode in parallel.
…le mock Bun's mock.module patches the shared module registry for the whole test run. use-optimizer.test.tsx replaces @/lib/image/ingest wholesale and only restores it in its own afterAll, which runs after collection has already resolved every file's imports; a separate file importing the real ingest.ts gets the stub instead. runWithConcurrency's bounding and ordering are already covered by lib/compress/__tests__/pool.test.ts.
jobsRef.current.length was read before the ingest await, so a second drop during a slow ingest saw the pre-ingest count and could bypass MAX_FILES. pendingIngestRef tracks files already claimed but not yet committed to jobsRef, so the next addFiles call sees an accurate starting count.
quality and outputFormat were sanitized but resize dimensions passed through raw; a large typed value reached the browser canvas path unclamped.
|
Contributor
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
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.
Why
What changed
Tests
The supersession and removal tests now also assert the first run's signal was aborted. A new test holds an ingest open and asserts the second `addFiles` sees the first drop's file count (it fails without the fix; verified by stashing). Three new cases cover the dimension clamp. 59 pass, 0 fail.
Notes for review