Skip to content
Source
Sign inSign up
TanStack/router

AbortController signal is not called after `pendingMs` #3014

Send to my agent
Closedcesardeazevedo(GitHub profile, opens in a new tab) opened this issue 3 comments

Which project does this relate to?

Router

Describe the bug

AbortController signal is not called after pendingMs and user leaves the route.

The following sandbox simulates a long data fetching of 10 seconds when entering profile route for the profile route and a 5 seconds pendingMs, the signal doesn't get called after 5 seconds.

Your Example Website or App

https://codesandbox.io/p/devbox/wm3ffd

Steps to Reproduce the Bug or Issue

  1. Click on profile link (profile loader will simulate a 10 seconds request)
  2. Wait for pendingComponent to render (pendingMs: 5 seconds for testing purposes)
  3. Click on home link right after pendingComponent renders.
  4. AbortController signal didn't got called and profile loader successfully fulfilled (should had been aborted as user left /profile route)

(abortController signal get's called just fine within pendingMs time)

Expected behavior

When user leaves a route, the abortController property of the loader should be called whenever there's a pending promise on it's loader.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 1.89.1

Additional context

No response

  1. Just to help whoever takes this one on.

    After debugging, here’s the sequence where the issue occurs:

    1. The timeout handler calls onReady.
    2. The router sets this.state.pendingMatches to undefined here.
    3. When navigating to another route before the loader completes, an abort is attempted here. Since this.state.pendingMatches is undefined, no abort controller runs.

    Before the timeout handler runs, this.state.pendingMatches holds the correct matches, and the abort happens as expected.

Sign in to join this conversation.