Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing a AbortSignal to cache.match #1505

Open
SamyPesse opened this issue Dec 21, 2023 · 2 comments
Open

Support passing a AbortSignal to cache.match #1505

SamyPesse opened this issue Dec 21, 2023 · 2 comments
Labels
feature request Request for Workers team to add a feature

Comments

@SamyPesse
Copy link

Because of how Cloudflare is tracing async executions (https://zuplo.com/blog/2022/03/04/the-script-will-never-generate-a-response), when implementing concurrent logic with Promise.race or similar, it's prefered to use a signal to abort any underlying fetch.

For example in my case I want to read from multiple caches in parallel, and one of them is the caches.default. But in theory the script might respond before all the caches finished responding.

It'd be great if we could pass a AbortSignal to cache.match:

const abort = new AbortController();
const response = await cache.match(request, { signal: abort.signal });
@jasnell jasnell added the feature request Request for Workers team to add a feature label Dec 21, 2023
@jasnell
Copy link
Member

jasnell commented Dec 21, 2023

fyi ... @irvinebroque

@jasnell
Copy link
Member

jasnell commented Jan 3, 2024

While we do already have some variances from the standard Cache API (https://developer.mozilla.org/en-US/docs/Web/API/Cache/match) I would be hesitant adding a non-standard option for a signal here. My preference would be to try to have the standard options updated to include a signal option that would parallel the option in fetch.

On a technical level, implementing this would not be difficult, however, and I think it would be a valuable addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for Workers team to add a feature
Projects
None yet
Development

No branches or pull requests

2 participants