11const { app } = require ( 'electron' ) ;
22const { BrowserWindow } = require ( 'electron' ) ;
33const { protocol } = require ( 'electron' ) ;
4- const { ipcMain } = require ( 'electron' ) ;
54const path = require ( 'path' ) ;
65const cProcess = require ( 'child_process' ) . spawn ;
76const portscanner = require ( 'portscanner' ) ;
@@ -98,7 +97,6 @@ function startSplashScreen() {
9897 throw new Error ( error . message ) ;
9998 }
10099
101- console . log ( "splashscreen " , dimensions . width , dimensions . height ) ;
102100 splashScreen = new BrowserWindow ( {
103101 width : dimensions . width ,
104102 height : dimensions . height ,
@@ -149,17 +147,12 @@ function startSocketApiBridge(port) {
149147 app [ 'mainWindow' ] = null ;
150148
151149 io . on ( 'connection' , ( socket ) => {
150+
152151 // we need to remove previously cache instances
153152 // otherwise it will fire the same event multiple depends how many time
154153 // live reload watch happen.
155154 socket . on ( 'disconnect' , function ( reason ) {
156155 console . log ( 'Got disconnect! Reason: ' + reason ) ;
157-
158- //todo fre: added to avoid memory leak when re-adding the eventlisteners
159- ipcMain . eventNames ( ) . forEach ( n =>
160- {
161- ipcMain . removeAllListeners ( n )
162- } ) ;
163156
164157 delete require . cache [ require . resolve ( './api/app' ) ] ;
165158 delete require . cache [ require . resolve ( './api/browserWindows' ) ] ;
@@ -249,17 +242,11 @@ function startAspCoreBackend(electronPort) {
249242
250243 let binFilePath = path . join ( currentBinPath , binaryFile ) ;
251244 var options = { cwd : currentBinPath } ;
252- console . log ( "Starting child process" , binFilePath , parameters , options ) ;
253245 apiProcess = cProcess ( binFilePath , parameters , options ) ;
254- console . log ( "Started" ) ;
246+
255247 apiProcess . stdout . on ( 'data' , ( data ) => {
256248 console . log ( `stdout: ${ data . toString ( ) } ` ) ;
257249 } ) ;
258- apiProcess . on ( 'exit' , ( code ) =>
259- {
260- console . log ( `child process exit: ${ code } ` ) ;
261- app . exit ( code ) ;
262- } ) ;
263250 }
264251}
265252
@@ -282,18 +269,11 @@ function startAspCoreBackendWithWatch(electronPort) {
282269 cwd : currentBinPath ,
283270 env : process . env ,
284271 } ;
285- console . log ( "Starting child process" , binFilePath , parameters , options ) ;
286272 apiProcess = cProcess ( 'dotnet' , parameters , options ) ;
287273
288- console . log ( "Started" ) ;
289274 apiProcess . stdout . on ( 'data' , ( data ) => {
290275 console . log ( `stdout: ${ data . toString ( ) } ` ) ;
291276 } ) ;
292- apiProcess . on ( 'exit' , ( code ) =>
293- {
294- console . log ( `child process exit: ${ code } ` ) ;
295- app . exit ( code ) ;
296- } ) ;
297277 }
298278}
299279
0 commit comments