jamaljsr / polar

One-click Bitcoin Lightning networks for local app development & testing
https://lightningpolar.com
MIT License
774 stars 145 forks source link

Bug: Docker containers not shutting down when closing GUI #521

Closed secondl1ght closed 7 months ago

secondl1ght commented 2 years ago

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):

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

jamaljsr commented 2 years ago

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

Abdulkbk commented 7 months ago

I will work on this @jamaljsr

jamaljsr commented 7 months ago

Sounds good. Thank you!

Abdulkbk commented 7 months ago

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.

jamaljsr commented 7 months ago

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(),
  },
}));
Abdulkbk commented 7 months ago

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 commented 7 months ago

I mocked ipcRenderer and it worked @jamaljsr.

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