File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @tanstack/devtools-event-bus ' : patch
3+ ---
4+
5+ Honor explicit client connection options when bundlers inject event bus defaults.
Original file line number Diff line number Diff line change @@ -89,18 +89,18 @@ export class ClientEventBus {
8989 this . #eventTarget. dispatchEvent ( new CustomEvent ( 'tanstack-connect-success' ) )
9090 }
9191 constructor ( {
92- port = 4206 ,
93- host = 'localhost' ,
94- protocol = 'http' ,
92+ port = getDefaultPort ( 4206 ) ,
93+ host = getDefaultHost ( 'localhost' ) ,
94+ protocol = getDefaultProtocol ( 'http' ) ,
9595 debug = false ,
9696 connectToServerBus = false ,
9797 } : ClientEventBusConfig = { } ) {
9898 this . #debug = debug
9999 this . #broadcastChannel = new BroadcastChannel ( 'tanstack-devtools' )
100100 this . #eventSource = null
101- this . #port = getDefaultPort ( port )
102- this . #host = getDefaultHost ( host )
103- this . #protocol = getDefaultProtocol ( protocol )
101+ this . #port = port
102+ this . #host = host
103+ this . #protocol = protocol
104104 this . #socket = null
105105 this . #connectToServerBus = connectToServerBus
106106 this . #eventTarget = this . getGlobalTarget ( )
Original file line number Diff line number Diff line change @@ -101,6 +101,34 @@ describe('ClientEventBus', () => {
101101 expect ( mockEventSourceInstances . length ) . toBe ( 0 )
102102 bus . stop ( )
103103 } )
104+
105+ it ( 'should prefer explicit config over bundler-injected defaults' , ( ) => {
106+ Object . assign ( globalThis , {
107+ __TANSTACK_DEVTOOLS_PORT__ : 4206 ,
108+ __TANSTACK_DEVTOOLS_HOST__ : 'localhost' ,
109+ __TANSTACK_DEVTOOLS_PROTOCOL__ : 'http' ,
110+ } )
111+
112+ let bus : ClientEventBus | undefined
113+ try {
114+ bus = new ClientEventBus ( {
115+ connectToServerBus : true ,
116+ port : 443 ,
117+ host : 'devtools.example.com' ,
118+ protocol : 'https' ,
119+ } )
120+ bus . start ( )
121+
122+ expect ( mockWebSocketInstances [ 0 ] . url ) . toBe (
123+ 'wss://devtools.example.com:443/__devtools/ws' ,
124+ )
125+ } finally {
126+ bus ?. stop ( )
127+ Reflect . deleteProperty ( globalThis , '__TANSTACK_DEVTOOLS_PORT__' )
128+ Reflect . deleteProperty ( globalThis , '__TANSTACK_DEVTOOLS_HOST__' )
129+ Reflect . deleteProperty ( globalThis , '__TANSTACK_DEVTOOLS_PROTOCOL__' )
130+ }
131+ } )
104132 } )
105133
106134 describe ( 'connectWebSocket with protocol' , ( ) => {
You can’t perform that action at this time.
0 commit comments