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

fix(react-router): ensure fetch abort works correctly even with pendingComponent #3181

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

leesb971204
Copy link

fixes #3014

Copy link

nx-cloud bot commented Jan 16, 2025

View your CI Pipeline Execution ↗ for commit eeeaeda.

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 4m 39s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 25s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-30 22:25:34 UTC

Copy link

pkg-pr-new bot commented Jan 16, 2025

Open in Stackblitz

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@3181

@tanstack/create-router

npm i https://pkg.pr.new/@tanstack/create-router@3181

@tanstack/create-start

npm i https://pkg.pr.new/@tanstack/create-start@3181

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/@tanstack/directive-functions-plugin@3181

@tanstack/react-cross-context

npm i https://pkg.pr.new/@tanstack/react-cross-context@3181

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@3181

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@3181

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@3181

@tanstack/react-router-with-query

npm i https://pkg.pr.new/@tanstack/react-router-with-query@3181

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@3181

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@3181

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@3181

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@3181

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@3181

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/@tanstack/server-functions-plugin@3181

@tanstack/start

npm i https://pkg.pr.new/@tanstack/start@3181

@tanstack/start-api-routes

npm i https://pkg.pr.new/@tanstack/start-api-routes@3181

@tanstack/start-config

npm i https://pkg.pr.new/@tanstack/start-config@3181

@tanstack/start-client

npm i https://pkg.pr.new/@tanstack/start-client@3181

@tanstack/start-plugin

npm i https://pkg.pr.new/@tanstack/start-plugin@3181

@tanstack/start-router-manifest

npm i https://pkg.pr.new/@tanstack/start-router-manifest@3181

@tanstack/start-server

npm i https://pkg.pr.new/@tanstack/start-server@3181

@tanstack/start-server-functions-client

npm i https://pkg.pr.new/@tanstack/start-server-functions-client@3181

@tanstack/start-server-functions-fetcher

npm i https://pkg.pr.new/@tanstack/start-server-functions-fetcher@3181

@tanstack/start-server-functions-handler

npm i https://pkg.pr.new/@tanstack/start-server-functions-handler@3181

@tanstack/start-server-functions-server

npm i https://pkg.pr.new/@tanstack/start-server-functions-server@3181

@tanstack/start-server-functions-ssr

npm i https://pkg.pr.new/@tanstack/start-server-functions-ssr@3181

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@3181

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@3181

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@3181

commit: eeeaeda

@schiller-manuel
Copy link
Contributor

can you please add a test for this?

…tly even with pendingComponent

Signed-off-by: leesb971204 <[email protected]>
@leesb971204
Copy link
Author

can you please add a test for this?

I have added and written the test cases as requested. Since this is my first attempt at writing test cases, I am unsure if they have been written correctly. I would greatly appreciate it if you could kindly review them and provide your feedback. For your reference, it seems that the code below needs to be placed at the very top of the file in my local environment for the test cases to work properly. Thank you so much in advance for your help!

/**
 * @vitest-environment jsdom
 */
import '@testing-library/jest-dom/vitest'

@leesb971204
Copy link
Author

can you please add a test for this?

I apologize for the misunderstanding earlier. To clarify the issue, when pendingMs is 0, the abort function operates correctly if there is no pendingComponent. However, if a pendingComponent is present, the abort function does not work as expected. I have made modifications to address this behavior. Considering that this might be the intended functionality, I believe it may be necessary to revise the title of the PR accordingly.

@schiller-manuel
Copy link
Contributor

this does not work with preloads. hover over a link, let the preload start. then click, wait for the pending component, navigate away. preload is not cancelled.

@leesb971204
Copy link
Author

leesb971204 commented Jan 22, 2025

this does not work with preloads. hover over a link, let the preload start. then click, wait for the pending component, navigate away. preload is not cancelled.

2025-01-22.3.50.05.mov

If the issue you mentioned about preload not working aligns with the behavior in the video, it seems unrelated to my work. I have reproduced this behavior in the latest main branch, and it does not appear to be a side effect of my changes. While I agree that preload(fetching posts in my video) should be aborted, the environment in which I worked had defaultPreload set to false, and I believe addressing this behavior should be treated as a separate issue. And I think hover action is related to cachedMatches not pendingMatches. Therefore, I think that the work regarding preload not functioning properly should be addressed in a new PR. What are your thoughts on this?

…d on browser location changes

Signed-off-by: leesb971204 <[email protected]>
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.

AbortController signal is not called after pendingMs
2 participants