File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
packages/query-devtools/src/contexts Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @tanstack/query-devtools ' : patch
3+ ---
4+
5+ fix(devtools): handle PiP open failures by resetting persisted state
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ type PiPContextType = {
2626 disabled : boolean
2727}
2828
29+ class PipOpenError extends Error { }
30+
2931const PiPContext = createContext < Accessor < PiPContextType > | undefined > (
3032 undefined ,
3133)
@@ -57,7 +59,7 @@ export const PiPProvider = (props: PiPProviderProps) => {
5759 )
5860
5961 if ( ! pip ) {
60- throw new Error (
62+ throw new PipOpenError (
6163 'Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.' ,
6264 )
6365 }
@@ -134,10 +136,20 @@ export const PiPProvider = (props: PiPProviderProps) => {
134136 createEffect ( ( ) => {
135137 const pip_open = ( props . localStore . pip_open ?? 'false' ) as 'true' | 'false'
136138 if ( pip_open === 'true' && ! props . disabled ) {
137- requestPipWindow (
138- Number ( window . innerWidth ) ,
139- Number ( props . localStore . height || PIP_DEFAULT_HEIGHT ) ,
140- )
139+ try {
140+ requestPipWindow (
141+ Number ( window . innerWidth ) ,
142+ Number ( props . localStore . height || PIP_DEFAULT_HEIGHT ) ,
143+ )
144+ } catch ( error ) {
145+ if ( error instanceof PipOpenError ) {
146+ console . error ( error . message )
147+ props . setLocalStore ( 'pip_open' , 'false' )
148+ props . setLocalStore ( 'open' , 'false' )
149+ return
150+ }
151+ throw error
152+ }
141153 }
142154 } )
143155
You can’t perform that action at this time.
0 commit comments