nicferrier / elnode

evented io webserver right inside your emacs.
http://nicferrier.github.com/elnode
GNU General Public License v3.0
477 stars 49 forks source link

Elnode is unusable on Emacs 26+ #106

Open jcaw opened 5 years ago

jcaw commented 5 years ago

Because of a quirk in how Emacs 25.1+ creates network processes, the flags server and nowait cannot both be set in make-network-process. Elnode sets both.

On Emacs 26.1, this is formalised and supplying both flags results in an error. This makes Elnode unusable on Emacs 26.1+. It crashes when it tries to start the server.

There's an open pull request, #105, which appears to fix this issue.

I've opened two pull requests to fix this, one for Master (#107) and one for MELPA (#108).

jcaw commented 5 years ago

In the meantime, overriding the method elnode/make-service with a patched version allows Elnode to be used. Add this to your init file to get Elnode working again:

;; Elnode doesn't work on Emacs 25.1+, because it sets both the `:server` and
;; `:nowait` flags. They can't both be set on Emacs 25.1+, so `:nowait` has to be 
;; dropped.
;;
;; Make sure the patch is applied *after* elnode is loaded.
(with-eval-after-load 'elnode
  (defun elnode/make-service (host port service-mappings request-handler defer-mode)
    "Make an actual TCP server."
    (let ((an-buf (get-buffer-create "*elnode-webserver*")))
      (make-network-process
       :name "*elnode-webserver-proc*"
       :buffer an-buf
       :server t
       ;; This flag is the only change in the patched in this version of the method.
       :nowait nil
       :host (cond
              ((equal host "localhost") 'local)
              ((equal host "*") nil)
              (t host))
       :service port
       :coding '(raw-text-unix . raw-text-unix)
       :family 'ipv4
       :filter 'elnode--filter
       :sentinel 'elnode--sentinel
       :log 'elnode--log-fn
       :plist (list
               :elnode-service-map service-mappings
               :elnode-http-handler request-handler
               :elnode-defer-mode defer-mode)))))
jcaw commented 5 years ago

The MELPA Recipe has been updated in leui of inactivity: https://github.com/melpa/melpa/issues/6184

Active fork here: https://github.com/jcaw/elnode

@nicferrier - I've given you push access to the forked Repo. Let me know if you'd like to move it back here when you have more time.