atlas-engineer / cl-electron

Lisp Interface to Electron.
BSD 3-Clause "New" or "Revised" License
18 stars 2 forks source link

Spawning a new window after killing all others #3

Closed aadcg closed 1 year ago

aadcg commented 1 year ago

Steps to reproduce:

> (launch)
> (defparameter window (make-instance 'browser-window))
> (kill window)
> (defparameter window (make-instance 'browser-window))

Couldn't write to #<SB-SYS:FD-STREAM for "socket 127.0.0.1:52720, peer: 127.0.0.1:3000" {100C80BEA3}>:
  Broken pipe
   [Condition of type SB-INT:BROKEN-PIPE]

After reading this explanation, it seems to me that our IPC mechanism to talk to Electron needs to be re-designed.

Ambrevar commented 1 year ago

Fixed with 792754de0ba75d4bff2ad9a0b15c28f3945d4510.

aadcg commented 1 year ago

Follow the stream of events below.

(progn
  (setf electron::*interface*
        (make-instance
         'electron:interface
         :electron-socket-path (uiop:xdg-runtime-dir "electron.socket")
         :lisp-socket-path (uiop:xdg-runtime-dir "lisp.socket"))) 
  (electron:launch)
  (sleep 1)
  (defparameter win (make-instance 'electron:browser-window)))

electron.socket and lisp.socket are created. A window pops up.

(kill win)

The window is killed, the process is killed and the sockets deleted. Therefore (no surprises):

(defparameter win2 (make-instance 'electron:browser-window))
=>
#<Syscall "connect" signalled error ENOENT(2) "No such file or directory" FD=7>
   [Condition of type IOLIB/SYSCALLS:ENOENT]

This is indeed Electron's default behaviour. And it's a good default.

The sockets are deleted when the electron process is killed since the OS sees it was started as electron /path/to/server.js /run/user/1000/electron.socket /run/user/1000/lisp.socket, so it deletes them automatically.

Long story short: this is a non-problem. It wasn't solved in the sense that everything's working as it should be. As always, the issue is between the keyboard and the chair.

jmercouris commented 1 year ago

Classic pebkac ;-)

Ambrevar commented 1 year ago

Long story short: this is a non-problem. It wasn't solved in the sense that everything's working as it should be. As always, the issue is between the keyboard and the chair.

I'm confused, is there a problem? Even a pebkac?

You seem to imply that making a window without a running instance could be expected to work nonetheless (e.g. by starting an instance automatically). Is that what you mean?

aadcg commented 1 year ago

You seem to imply that making a window without a running instance could be expected to work nonetheless

No, I think Electron's default behaviour makes sense.

From the very start, this is a misinterpretation of mine (a pebkac) rather than a real issue - that's what I have clarified. In other words, the conclusion from this issue is not "it has been solved", but "it's expected behaviour" and a pebkac of mine :)

Ambrevar commented 1 year ago

OK!