For me the following also hangs emacs. The problem seems to me that
(accept-process-output stream 0.05) in network-stream-get-response does not
return even though it has a timeout of .05.
(let ()
(run-with-timer 0 nil #'url-retrieve"https://www.gnu.org/" #'ignore)
(make-process :name "echo" :command '("echo")
:sentinel (lambda (_p _e)
(with-current-buffer (generate-new-buffer " *debug")
(run-with-timer 0 nil #'open-network-stream
"testing" (current-buffer)
"smtp.gmail.com" 587
:type 'starttls
:return-list t
:warn-unless-encrypted t
:capability-command
"EHLOwww.gnu.org\r\n"
:end-of-command "^[0-9]+ .*\r\n"
:success "^2.*\n"
:always-query-capabilities t
:starttls-function
(lambda (capabilities)
(and (string-match "[
-]STARTTLS" capabilities)
"STARTTLS\r\n"))
:client-certificate t
:use-starttls-if-possible t)))))