polar icon indicating copy to clipboard operation
polar copied to clipboard

Bug: Docker containers not shutting down when closing GUI

Open secondl1ght opened this issue 2 years ago • 3 comments

Describe the bug When exiting out of the application and then running docker ps it looks like the docker containers do not shut down and continue running after the GUI has been closed.

To Reproduce Steps to reproduce the behavior:

  1. Run Polar and launch a network
  2. Close out of the GUI
  3. Check docker containers in terminal

Expected behavior Docker containers get shutdown when GUI is closed.

Desktop (please complete the following information):

  • OS: PopOS
  • Polar Version: v1.3.0
  • Docker Version: 20.10.11
  • Docker Compose Version: 1.29.2

Additional context If I have missed something please let me know.

secondl1ght avatar Dec 09 '21 00:12 secondl1ght

Thanks for the feedback. This has indeed been an annoyance to me every once in a while.

jamaljsr avatar Dec 09 '21 22:12 jamaljsr

I will work on this @jamaljsr

Abdulkbk avatar Mar 02 '24 02:03 Abdulkbk

Sounds good. Thank you!

jamaljsr avatar Mar 02 '24 03:03 jamaljsr

HI @jamaljsr, I am having a blocker.

I worked on a solution for this issue but I noticed that the test failed.

My implementation involves leveraging electron's 'before-quit' when a user exits polar and sending a message to the renderer process from main process. Now the blocker I have is that I imported ipcRenderer from electron in a react component and I used it to listen to messages from the main process. This works fine during development but a test always fails.

I tried a couple of solutions I found online including adding a preload.js script and exposing ipcRenderer through contextBridge. None seems to be working.

So I would appreciate it if you could advise me on how I can access ipcRendrer or point me to resources. I think that would really help.

Abdulkbk avatar Mar 07 '24 15:03 Abdulkbk

Hey @Abdulkbk, have you tried mocking the ipcRenderer's methods using jest.fn()? I've done this before in the ipcService tests.

Another approach that may work is to use jest.mock('electron'); to mock the entire library, but this way requires filling in more of the exposed API.

Something like this:

jest.mock('electron', () => ({
  ipcRenderer: {
    on: jest.fn(),
    removeAllListeners: jest.fn(),
  },
}));

jamaljsr avatar Mar 08 '24 22:03 jamaljsr

Hey @Abdulkbk, have you tried mocking the ipcRenderer's methods using jest.fn()? I've done this before in the ipcService tests.

Another approach that may work is to use jest.mock('electron'); to mock the entire library, but this way requires filling in more of the exposed API.

Something like this:

jest.mock('electron', () => ({
  ipcRenderer: {
    on: jest.fn(),
    removeAllListeners: jest.fn(),
  },
}));

Alright. I would mock ipcRenderer's method and see if the test will pass.

Abdulkbk avatar Mar 09 '24 13:03 Abdulkbk

I mocked ipcRenderer and it worked @jamaljsr.

I've submitted a PR. I'll wait for your review and feedback. Thank you

Abdulkbk avatar Mar 10 '24 16:03 Abdulkbk