I was finally able to get the backtrace for end-of-file after rebuilding emacs without those 2 assertion check flags.
So the last elisp-land function to propagate the error was in url-http.el:
=====
(defun url-http-activate-callback ()
"Activate callback specified when this buffer was created."
(url-http-mark-connection-as-free (url-host url-current-object)
(url-port url-current-object)
url-http-process)
(url-http-debug "Activating callback in buffer (%s): %S %S"
(buffer-name) url-callback-function url-callback-arguments)
(apply url-callback-function url-callback-arguments))
=====
I see that url-http-debug form but it is not run because the error appears too soon and the user does not have change to hit C-g to make the info print in url-http-debug. So how about printing that info if "(apply url-callback-function url-callback-arguments)" results in error?
With the above "melpa-fake" archive from my gist.github.com and a modified version of url-http-activate-callback as below:
=====
(defun url-http-activate-callback ()
"Activate callback specified when this buffer was created."
(url-http-mark-connection-as-free (url-host url-current-object)
(url-port url-current-object)
url-http-process)
(url-http-debug "Activating callback in buffer (%s): %S %S"
(buffer-name) url-callback-function url-callback-arguments)
(message "url-callback-function: %S" url-callback-function)
(apply url-callback-function url-callback-arguments))
=====
I get:
=====
?
?" nil noerror "incomprehensible buffer" url-insert-buffer-contents kill-buffer t package--update-downloads-in-progress signal buffer-string expand-file-name format "archives/%s" read-from-string make-directory write-region silent package--check-signature 256 <byte-code> [write-region nil silent mapconcat epg-signature-to-string "
" ".signed"] 7 "
(fn &optional GOOD-SIGS)" "\301\300!\207" [package--update-downloads-in-progress] package-unsigned-archives] 20 "
(fn STATUS)"]
error in process filter: End of file during parsing [2 times]
=====
So can we have something like:
- If (apply url-callback-function url-callback-arguments) returns an error, then extract the url being fetched from url-callback-function and print some like "Error incurred when when processing XYZ url.". In this case, we know that read-from-string threw an error. So we can even say that the string fetched from XYZ url could not be parsed as a valid lisp form (it does not necessarily mean that it read an empty string; in this case the lisp form was incomplete).
The value of url-callback-function has a lot of other info which I do not understand (I spy mainly the URL in it and "read-from-string" in it). But may be using all the info in that var, we can have a well constructed error message that can tell us what exactly went wrong. What do you think?