Skip to content

Fix infinite spinner when 400 error occurs due to 50k node limit by s…#11901

Open
Shyam-123pandey wants to merge 3 commits intoopenstreetmap:developfrom
Shyam-123pandey:fix-400-spinner-clean
Open

Fix infinite spinner when 400 error occurs due to 50k node limit by s…#11901
Shyam-123pandey wants to merge 3 commits intoopenstreetmap:developfrom
Shyam-123pandey:fix-400-spinner-clean

Conversation

@Shyam-123pandey
Copy link

@Shyam-123pandey Shyam-123pandey commented Feb 20, 2026

Fix infinite spinner when OSM API returns 400 for large bbox #11459

What this fixes

When the OSM API returns a 400 Bad Request for /map.json?bbox=... (typically caused by the 50k node limit), the editor keeps retrying the same tile and the loading spinner never stops.

Even after API requests stop in the network tab, the tile remains in _tileCache.inflight, so the spinner continues indefinitely.

What was changed

  • Added safe handling for 400 responses
  • Subdivide tiles when possible (up to a max depth)
  • Properly clear _tileCache.inflight and _tileCache.toLoad
  • Ensure the spinner stops once all inflight requests are resolved

Result

Please take a look of vedio: https://drive.google.com/file/d/1-3UsnZWG6jUg05__sEQULTYYidnYVkZg/view?usp=drive_link

  • No infinite spinner
  • No repeated 400 requests
  • Editor returns to a stable state

Tested by forcing a bbox that exceeds the 50k node limit.
I have added a vedio in comment of this issue if want please you can check for fixes.
Thanks

Copilot AI review requested due to automatic review settings February 20, 2026 15:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request attempts to fix an infinite spinner issue that occurs when the OpenStreetMap API returns a 400 Bad Request error due to exceeding the 50,000 node limit for a bounding box query. The fix introduces tile subdivision to break large tiles into smaller quadrants when a 400 error is encountered, and adds state management with a new _isLoading flag to track loading status.

Changes:

  • Added 400 error handling with automatic tile subdivision up to 3 levels deep
  • Introduced _isLoading flag to track loading state independently of inflight requests
  • Modified retry logic to handle 400 errors differently from rate limit errors


return;
}

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

There are no test cases for the new 400 error handling and tile subdivision logic. Given that this fix addresses a critical bug (infinite spinner), test coverage is important to prevent regression.

Consider adding tests that verify:

  1. A 400 error triggers tile subdivision into 4 child tiles
  2. Child tiles are loaded with incremented depth
  3. Subdivision stops at MAX_SUBDIVISION_DEPTH
  4. The spinner stops after subdivision completes
  5. No retry occurs for 400 errors after subdivision
Suggested change
// At or beyond MAX_SUBDIVISION_DEPTH, do not retry 400 errors.
return;

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

right that additional test coverage would be beneficial, especially around subdivision and spinner behavior.
However, since this PR is focused on resolving the immediate infinite spinner issue with minimal scope change, I kept the changes isolated to the service logic.

I’d be happy to follow up with a separate PR that adds targeted tests for 400 handling and subdivision depth limits to avoid mixing behavioral fixes with broader test additions.

@Shyam-123pandey

This comment has been minimized.

@Shyam-123pandey

This comment has been minimized.

@Shyam-123pandey

This comment was marked as spam.

@tordans

This comment was marked as off-topic.

Shyam-123pandey and others added 2 commits February 26, 2026 12:11
I am changing variable name at this time

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Shyam-123pandey
Copy link
Author

Hello Sir, good morning.
Almost thing have been resolved, just in one things I have doubt please check above, and suggest me furthur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants