gzuidhof / zarr.js

Javascript implementation of Zarr
https://guido.io/zarr.js
Apache License 2.0
133 stars 23 forks source link

fix(error): Fix error passthrough in queued tasks #145

Closed az0uz closed 11 months ago

az0uz commented 1 year ago

fixes #140

Errors being thrown by chunkGetItem (and underlying storage requests) are uncaught.

The use of the PQueue class will both emit an error event and throw if awaiting the Promise returned by the queue.add method.

To prevent this issue, I created an array of queue.add promises, and await for all those promises instead of using queue.onIdle().

Using the error event will still be considered as uncaught errors since nothing is awaiting the queue.add promises.

az0uz commented 1 year ago

Right now, when there is a network issue in a chunk request, the get will still complete and return data, with that errored chunk data containing zeros, this change will fix that, and correctly throw on that method if any of the chunk requests errored. This will also throw the underlying AbortError when passing an AbortSignal to the Store through StoreOptions.

toloudis commented 12 months ago

I can confirm this is fixing a bug we have in our attempt to write a proxy Store to cache chunk requests.