@@ -44,35 +44,46 @@ export function AppContent() {
4444 // Branding is now applied by AppShell via ConsoleLayout
4545
4646 useEffect ( ( ) => {
47- initializeDataSource ( ) ;
48- } , [ ] ) ;
47+ let cancelled = false ;
4948
50- async function initializeDataSource ( ) {
51- try {
52- const adapter = new ObjectStackAdapter ( {
53- baseUrl : '' ,
54- autoReconnect : true ,
55- maxReconnectAttempts : 5 ,
56- reconnectDelay : 1000 ,
57- cache : { maxSize : 50 , ttl : 300_000 } ,
58- } ) ;
49+ async function initializeDataSource ( ) {
50+ try {
51+ const adapter = new ObjectStackAdapter ( {
52+ baseUrl : '' ,
53+ autoReconnect : true ,
54+ maxReconnectAttempts : 5 ,
55+ reconnectDelay : 1000 ,
56+ cache : { maxSize : 50 , ttl : 300_000 } ,
57+ } ) ;
5958
60- // Monitor connection state
61- adapter . onConnectionStateChange ( ( event ) => {
62- setConnectionState ( event . state ) ;
63- if ( event . error ) {
64- console . error ( '[Console] Connection error:' , event . error ) ;
65- }
66- } ) ;
59+ // Monitor connection state
60+ adapter . onConnectionStateChange ( ( event ) => {
61+ if ( cancelled ) return ;
62+ setConnectionState ( event . state ) ;
63+ if ( event . error ) {
64+ console . error ( '[Console] Connection error:' , event . error ) ;
65+ }
66+ } ) ;
6767
68- await adapter . connect ( ) ;
68+ await adapter . connect ( ) ;
6969
70- setDataSource ( adapter ) ;
71- } catch ( err ) {
72- console . error ( '[Console] Failed to initialize:' , err ) ;
73- setConnectionState ( 'error' ) ;
70+ if ( ! cancelled ) {
71+ setDataSource ( adapter ) ;
72+ }
73+ } catch ( err ) {
74+ if ( ! cancelled ) {
75+ console . error ( '[Console] Failed to initialize:' , err ) ;
76+ setConnectionState ( 'error' ) ;
77+ }
78+ }
7479 }
75- }
80+
81+ initializeDataSource ( ) ;
82+
83+ return ( ) => {
84+ cancelled = true ;
85+ } ;
86+ } , [ ] ) ;
7687
7788 const allObjects = appConfig . objects || [ ] ;
7889
0 commit comments