tkf / emacs-request

Request.el -- Easy HTTP request for Emacs Lisp
http://tkf.github.com/emacs-request/
GNU General Public License v3.0
617 stars 91 forks source link

Latest request release (0.3.2) is partially incompatible with Eldev #219

Open edran opened 1 year ago

edran commented 1 year ago

Yesterday I opened an issue in the Eldev tracker to figure out a request crash that is happening when running one of the basic blocking GET examples in Eldev: https://github.com/doublep/eldev/issues/79

Turns out this particular issue was fixed in 0183da8, but the latest MELPA stable release doesn't include this commit (and many others).

Would it be possible to release a new version of request on MELPA?


For completeness (and SEO), here's a rough reproduction of the issue:

$ cat request-test.el
(require 'request)
(require 'buttercup)

(defun httpbin-get-test (sync)
  (interactive)
  (request "http://httpbin.org/get"
        :params '(("key" . "value") ("key2" . "value2"))
        :sync sync
        :parser 'json-read
        :success (cl-function
                  (lambda (&key data &allow-other-keys)
                    (message "I sent: %S" (assoc-default 'args data))))))

(describe "`httpbin-get-test' will"
  (describe "with :sync f"
    (it "successfully runs"
      (expect (type-of (httpbin-get-test 'nil)) :to-be 'request-response)))
  (describe "with :sync t"
    (it "crashes :-( (but shouldn't?)"
      (expect (type-of (httpbin-get-test t)) :to-be 'request-response))))

On a terminal with Eldev setup and initialised:

$ eldev test
Running 2 specs.

`httpbin-get-test' will
  with :sync f
    successfully runs (4.05ms)
  with :sync t
    crashes :-( (but shouldn't?)  FAILED (0.33ms)

========================================
`httpbin-get-test' will with :sync t crashes :-( (but shouldn't?)

Traceback (most recent call last):
  (type-of (httpbin-get-test t))
  httpbin-get-test(t)
  request("http://httpbin.org/get" :params (("key" . "value") ("key2" . "value2")) :sync t :parser json-read :success (closure ((sync . t) t) (&rest --cl-rest--) "\n\n(fn &key DATA &allow-other-keys)" (let* ((data (car (cdr (plist-member --cl-rest-- ':data))))) (message "I sent: %S" (assoc-default 'args data)))))
  apply(request--curl-sync "http://httpbin.org/get?key=value&key2=value2" (:params (("key" . "value") ("key2" . "value2")) :sync t :parser json-read :success (closure ((sync . t) t) (&rest --cl-rest--) "\n\n(fn &key DATA &allow-other-keys)" (let* ((data (car (cdr (plist-member --cl-rest-- ':data))))) (message "I sent: %S" (assoc-default 'args data)))) :error #[128 "\302\300\303\301\"\"\207" [request-default-error-callback ("http://httpbin.org/get") apply append] 6 "\n\n(fn &rest ARGS2)"] :url "http://httpbin.org/get?key=value&key2=value2" :response #s(request-response nil nil nil nil nil "http://httpbin.org/get?key=value&key2=value2" nil #1 #<buffer  *request curl*-69972> nil nil curl nil) :encoding utf-8))
  request--curl-sync("http://httpbin.org/get?key=value&key2=value2" :params (("key" . "value") ("key2" . "value2")) :sync t :parser json-read :success (closure ((sync . t) t) (&rest --cl-rest--) "\n\n(fn &key DATA &allow-other-keys)" (let* ((data (car (cdr (plist-member --cl-rest-- ':data))))) (message "I sent: %S" (assoc-default 'args data)))) :error #[128 "\302\300\303\301\"\"\207" [request-default-error-callback ("http://httpbin.org/get") apply append] 6 "\n\n(fn &rest ARGS2)"] :url "http://httpbin.org/get?key=value&key2=value2" :response #s(request-response nil nil nil nil nil "http://httpbin.org/get?key=value&key2=value2" nil (:params (("key" . "value") ("key2" . "value2")) :sync t :parser json-read :success (closure ((sync . t) t) (&rest --cl-rest--) "\n\n(fn &key DATA &allow-other-keys)" (let* ((data (car (cdr (plist-member --cl-rest-- ':data))))) (message "I sent: %S" (assoc-default 'args data)))) :error #[128 "\302\300\303\301\"\"\207" [request-default-error-callback ("http://httpbin.org/get") apply append] 6 "\n\n(fn &rest ARGS2)"] :url "http://httpbin.org/get?key=value&key2=value2" :response #1 :encoding utf-8) #<buffer  *request curl*-69972> nil nil curl nil) :encoding utf-8)
  request-auto-revert-notify-rm-watch()
error: (void-variable auto-revert-notify-watch-descriptor-hash-list)

Ran 2 specs, 1 failed, in 6.22ms.
1 Buttercup test failed

I can also confirm that buttercup runs both correctly if launched interactively within Emacs.


System info:

$ eldev dependencies
request 0.3.2

$ emacs --version
GNU Emacs 28.2
Copyright (C) 2022 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

$ uname -a
Darwin eschatologist 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov  6 23:31:13 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000 arm64
GiovanH commented 10 months ago

This is not just an eldev issue, this also happens with other packages or when just making requests. And the current version works, yes. The package needs to be rebuilt.