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

Aborted API requests can stay in the inflight cache #1451

Open
bhousel opened this issue May 29, 2024 · 4 comments
Open

Aborted API requests can stay in the inflight cache #1451

bhousel opened this issue May 29, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@bhousel
Copy link
Contributor

bhousel commented May 29, 2024

This code is in the OSM service, but we might have this issue in other places where we fetch data..

_fetch(resource, { signal: controller.signal })
.then(utilFetchResponse)
.then(result => gotResult(null, result))
.catch(err => {
if (err.name === 'AbortError') return; // ok
if (err.name === 'FetchError') {
gotResult(err);
return;
}
});

This is unfortunately because we are mixing Promise and callback style code.
When the fetch is aborted, it returns and skips calling the errback, (amusingly the comment says // ok).
The errback is where the request would be removed from the _tileCache.inflight cache .

Screenshot 2024-05-29 at 10 16 12 AM

What we really should do is:

  • Anyplace we have an inflight request cache, it should be keyed off the url+method, not the tileid.
  • The fetch should have a finally block to remove the request from the inflight cache.
  • While we're at it, the AbortSignal can now have a timeout. This is a thing that all modern browsers support now - details. The default fetch timeout in Chrome is 300 seconds, but we should probably drop most requests after like 5-10sec.
  • (Can any requests take longer than 300 seconds? Posting a changeset? Maybe a sneaky bug lives there).
@bhousel bhousel added the bug Something isn't working label May 29, 2024
@bhousel bhousel self-assigned this May 29, 2024
@eneerhut
Copy link

@bhousel what implications does this have for the user's experience in Rapid?

@bhousel
Copy link
Contributor Author

bhousel commented Sep 26, 2024

what implications does this have for the user's experience in Rapid?

When the bug is triggered, it would show up as a missing square of OSM data that never loads.

@eneerhut
Copy link

I feel like I might have encountered this. Do you have a rough idea of how often this might occur?

@bhousel
Copy link
Contributor Author

bhousel commented Sep 26, 2024

I feel like I might have encountered this. Do you have a rough idea of how often this might occur?

I'm not sure - it would probably depend on how much scrolling and zooming the user is doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants