Skip to content
Source
Sign inSign up
TanStack/query

Devtools crashes under TrustedTypes #5417

Send to my agent
ClosedJack-Works(GitHub profile, opens in a new tab) opened this issue 11 comments

Describe the bug

Crash

image

Your minimal, reproducible example

N/A

Steps to reproduce

Add a TrustedType policy before rendering the devtool.

Expected behavior

Do not use dangerouslySetInnerHTML.

https://github.com/TanStack/query/blob/fd02255066ac3a136f6b62863387c486d0d560fc/packages/react-query-devtools/src/devtools.tsx#L532

I see a nonce option but we cannot change the CSP header to do that. The HTML rendered can be static if you use CSS variables to replace them, or you can use CSSOM to insert CSS rules manually tooSheetElement.sheet

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Chrome

Tanstack Query adapter

None

TanStack Query version

4.29.7

TypeScript version

No response

Additional context

No response

  1. can you try with v5 please, we have new devtools there

  2. TkDodo added labelspackage: react-query-devtools

  3. @Jack-Works have you tried the devtools in v5 ?

  4. @Jack-Works have you tried the devtools in v5 ?

    can I use it with react-query v4?

  5. can I use it with react-query v4?

    no

  6. I think this is fixed in v5.

  7. TkDodo closed this

  8. TkDodo added labelsv5

  9. img

    hello @TkDodo I think this is not fixed in v5. A transitive dependency node_modules/.pnpm/goober@2.1.13_csstype@3.1.2/node_modules/goober/dist/goober.modern.js does not work with trustedTypes.

    img
  10. can you show a reproduction please

  11. can you show a reproduction please

    Yes! By adding this to the HTML you can reproduce this. (Note only Chrome supports Trusted Types for now)

    <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'">

    If you need a playground, https://stackblitz.com/edit/github-vbuic1?file=index.html (a fork of react-query playground https://stackblitz.com/github/TanStack/query/tree/main/examples/react/simple with only the addition HTML above)

  12. TkDodo reopened this

  13. TkDodo added labelsbug

  14. TkDodo removed labelspackage: react-query-devtools

  15. TkDodo added labelspackage: query-devtools

  16. thanks for the reproduction @Jack-Works . How do we fix it?

  17. @ardeora fyi

  18. this hasn't been worked on for quite some months. If someone wants to work on this, I can re-open it. Otherwise, we'll just accept it as a known limitation

  19. TkDodo closed this

Sign in to join this conversation.