Skip to content

@tanstack/react-query doesn't work when bootstraped alongside sentry. #91

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

Open
KoCoder opened this issue Apr 16, 2025 · 3 comments
Open

Comments

@KoCoder
Copy link

KoCoder commented Apr 16, 2025

Which project does this relate to?

Create Tanstack App

Describe the bug

@tanstack/react-query breaks, when Sentry is installed (atleast using create-tsrouter-app)

Your Example Website or App

https://github.com/KoCoder/tsrouter-sentry-query

Steps to Reproduce the Bug or Issue

  1. npx create-tsrouter-app@latest --add-ons
  2. Select: Start, (tRPC), Query and Sentry
  3. Start the development Server.
  4. Navigate to /demo/tanstack-query.
    (On Firefox/Zen:) Now you should see an Error Message: TypeError: router.ClientSsr is undefined.
    (On Chome:) Now you should see an Error Message: Cannot read properties of undefined (reading 'getStreamedValue')
    These exceptions get thrown inside the _experimental_beforeQuery Method @tanstack/react-router-with-query/index.tsx#L69
    Now I've bootstrapped another ts-app without Sentry. Tanstack-Query works now. Currently I'm trying to find the root-cause of this.

Expected behavior

I have expected that a newly created application works out of the box, without the exception mentioned above.

Screenshots or Videos

Image

Platform

  • OS: Arch Linux (6.13.8-arch1-1)
  • Browser: Chrome, Firefox (Zen-Browser)
    • Chrome-Version: 134.0.6998.88 (Official Build) (64-bit)
    • Zen-Version: 1.10.3b (Firefox 136.0.4) (64-bit)

Additional context

No response

@KoCoder
Copy link
Author

KoCoder commented Apr 16, 2025

I think this has something todo with the Sentry.tanstackRouterBrowserTracingIntegration(router) call in router.tsx#L52. To be more precise the router instance handed to the sentry integration.
Why don't we call createRouter() once in the router.tsx file, but instead import it in client.tsx and ssr.tsx? Are there any Problems associated by calling the createRouter() function in router.tsx and importing that router instance from client.tsx?

@jherr
Copy link
Collaborator

jherr commented Apr 16, 2025

There is a current PR to revise the sentry add-on. I'll check that today and I'll check this combination.

@jherr
Copy link
Collaborator

jherr commented Apr 16, 2025

LGTM to me now.

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

No branches or pull requests

2 participants