@@ -27,6 +27,12 @@ let isInstalled = false;
2727let isInstalledToDefaultSession = false ;
2828let devtronSW : Electron . ServiceWorkerMain ;
2929
30+ /**
31+ * Count the number of IPC calls that were made before the service worker was ready.
32+ * Used for logging purposes.
33+ */
34+ let untrackedIpcCalls = 0 ;
35+
3036const isPayloadWithUuid = ( payload : any [ ] ) : boolean => {
3137 // If the first argument is an object with __uuid__devtron then it is a custom payload
3238 return (
@@ -67,7 +73,10 @@ function trackIpcEvent({
6773 if ( excludedIpcChannels . includes ( channel ) ) return ;
6874
6975 if ( ! devtronSW ) {
70- logger . warn ( 'The service-worker for Devtron is not registered yet. Cannot track IPC event.' ) ;
76+ logger . info (
77+ `The service worker for Devtron is not registered yet. Cannot track ${ direction } IPC event for channel ${ channel } .` ,
78+ ) ;
79+ untrackedIpcCalls ++ ;
7180 return ;
7281 }
7382
@@ -415,7 +424,12 @@ async function install(options: InstallOptions = {}) {
415424 const extensionPath = path . resolve ( serviceWorkerPreloadPath , '..' , '..' , 'extension' ) ;
416425 devtron = await ses . extensions . loadExtension ( extensionPath , { allowFileAccess : true } ) ;
417426 await startServiceWorker ( ses , devtron ) ;
418- logger . info ( 'Devtron loaded successfully' ) ;
427+ if ( untrackedIpcCalls > 0 ) {
428+ logger . warn (
429+ `${ untrackedIpcCalls } untracked IPC events were dispatched before the service worker was ready.` ,
430+ ) ;
431+ }
432+ logger . info ( 'Devtron service worker loaded successfully' ) ;
419433 } catch ( error ) {
420434 logger . error ( 'Failed to load Devtron:' , error ) ;
421435 }
@@ -440,7 +454,7 @@ async function getEvents(): Promise<IpcEventDataIndexed[]> {
440454 }
441455
442456 if ( ! devtronSW ) {
443- logger . warn ( 'Devtron service- worker is not registered yet. Cannot get IPC events.' ) ;
457+ logger . warn ( 'Devtron service worker is not registered yet. Cannot get IPC events.' ) ;
444458 return [ ] ;
445459 }
446460
0 commit comments