Skip to content

fix(geotiff): reject decodes when the decoder worker fails - #771

Merged
kylebarron merged 3 commits into
developmentseed:mainfrom
charlieforward9:fix/geotiff-worker-error
Oct 22, 2026
Merged

kylebarron merged 3 commits into
developmentseed:mainfrom
charlieforward9:fix/geotiff-worker-error

Conversation

@charlieforward9

Copy link
Copy Markdown
Contributor

Note

This PR was written by Claude (Claude Code), not by @charlieforward9.

If the decoder worker fails to load (e.g. Vite pre-bundling moves worker.js, as in #364) or throws outside a job, WorkerWrapper never hears about it, so every DecoderPool.decode() stays pending: COGLayer tiles are fetched but never render, with no error.

WorkerWrapper now listens for error, rejects that worker's pending and later jobs, and is no longer picked while another worker still works. The new tests/pool.test.ts fails without the change.

WorkerWrapper only listened for `message`, so a worker that failed to
load (e.g. a bundler serving the wrong worker URL) or threw outside a
job never replied, and every DecoderPool.decode() promise stayed
pending forever. Tiles were fetched but never rendered, with no error.

Listen for `error`: reject the wrapper's pending jobs and remember the
failure so jobs submitted afterwards reject too, since a failed load
usually fires before the first tile is decoded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the fix label Oct 22, 2026
Comment thread packages/geotiff/src/pool/wrapper.ts Resolved
kylebarron and others added 2 commits October 22, 2026 14:50
The old comment stated the outcome ("never the least loaded") without
saying how `jobCount` causes it. Document the getter instead: the pool
sends each decode to the worker with the fewest jobs, so reporting
`Infinity` keeps a failed worker last until every worker has failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…load

A worker can keep running after an uncaught error, but the pool never
sends it another job, so terminate it rather than hold its thread and
memory for the life of the pool. Terminating a worker that failed to
load does nothing.

Browsers fire a plain `Event`, with no message, only when the worker
script fails to load (404, wrong MIME type, failed import), so say
"failed to load" in that case instead of a bare "failed".

Also document on `DecoderPool.decode` that it now rejects when its
worker fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@kylebarron
kylebarron merged commit f510de2 into developmentseed:main Oct 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants