From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Aaron Zeng" Newsgroups: gmane.emacs.bugs Subject: bug#71295: 29.3; url-retrieve-synchronously does not timeout if initial connection hangs Date: Mon, 03 Jun 2024 20:09:03 -0400 Message-ID: <19e5cb88-48a2-46a2-b9e9-c4a9c9198bb5@app.fastmail.com> References: <86bk4ko3lv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20768"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.11.0-alpha0-491-g033e30d24-fm-20240520.001-g033e30d2 Cc: 71295@debbugs.gnu.org, azeng@janestreet.com To: "Eli Zaretskii" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 04 02:10:16 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sEHkl-00058Z-N2 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jun 2024 02:10:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEHkN-0002pw-QQ; Mon, 03 Jun 2024 20:09:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEHkL-0002pX-Tj for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 20:09:49 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEHkL-0001m9-Cf for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 20:09:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEHkY-0008Gy-1i for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 20:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Aaron Zeng" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Jun 2024 00:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71295 X-GNU-PR-Package: emacs Original-Received: via spool by 71295-submit@debbugs.gnu.org id=B71295.171745978731768 (code B ref 71295); Tue, 04 Jun 2024 00:10:02 +0000 Original-Received: (at 71295) by debbugs.gnu.org; 4 Jun 2024 00:09:47 +0000 Original-Received: from localhost ([127.0.0.1]:55970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEHkJ-0008GJ-76 for submit@debbugs.gnu.org; Mon, 03 Jun 2024 20:09:47 -0400 Original-Received: from fhigh7-smtp.messagingengine.com ([103.168.172.158]:52295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEHkE-0008Fv-8m for 71295@debbugs.gnu.org; Mon, 03 Jun 2024 20:09:46 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id F116E114014E; Mon, 3 Jun 2024 20:09:23 -0400 (EDT) Original-Received: from imap46 ([10.202.2.96]) by compute4.internal (MEProxy); Mon, 03 Jun 2024 20:09:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bcc32.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1717459763; x=1717546163; bh=LrtRCnBWJJ mOPFwa5jmsTug7QAod+e+FygJ2riaCcsE=; b=A6MD7Qu6nbehMLBknU8FhAwGac VTUH0fetsfQKvGdTwIgQoz6s0ybhXV0NUjkXqvP8gC+Z/UsII2dEUkBYOPBBZ0el jPZ+p3TL3W9/DbEuokruJLQSNQiNG1Qr7d5LuD+tJCsgSQBKpaAyL+28plnlCxmB /ozhB8l2JzvGuGBj8Lj72ppEZ6/YvT8SO480RUSrylHtCAprsalMmsdB0jN7uzRd OZfmgH/BzLotNrUd9/EZGetrMOZpD4d0btMVIriGlHy8ceiFERM50vpfsuQLuaHl 01nJeuvofSCTXgdLwwygo4vscFAqPPnpgoC9e6R+pZCL+VCdE8jdGC7smoOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1717459763; x=1717546163; bh=LrtRCnBWJJmOPFwa5jmsTug7QAod +e+FygJ2riaCcsE=; b=J4aq2Pz/iTZsc0vIBi5Wx+zTl0STWOabqBEHsHO6Ow9L aS27kFFBXE1QsBSUaICeRMuH2m4W2hiSo6ovK7R4y3Hp5bZ+lzkKmuOwPOs4b2N+ 6wxcAoHXeBZivdHOLSfek8h6UD/Z7aNHxPykkVKR/9qpXbKKzxe1k3Urg9Ivz6l2 N8colNm/mkQ1wuVKFQAhYapLRb9EnuXG5OmK6cxE5//BW+POXfHDSP5D/Qws43vS dyHaiQJPPKKPAIWll5N0De78PlEU9RhjLAfi344OYA90LZ6i9s7/9gmUfrsWUZFX 9BPeefeEiDsxM7AcQnpHy+mwOzWcrazh16BbU4W0zQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelfedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftegr rhhonhcukggvnhhgfdcuoeiisegstggtfedvrdgtohhmqeenucggtffrrghtthgvrhhnpe dtjedujeeffeduffdvtddvkefgvdefveejtdevkeeiieetuddtgefhueejtedtkeenucff ohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepiiessggttgefvddrtghomh X-ME-Proxy: Feedback-ID: iba994645:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9EBAA2A20077; Mon, 3 Jun 2024 20:09:23 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <86bk4ko3lv.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286497 Archived-At: On Sat, Jun 1, 2024, at 15:38, Eli Zaretskii wrote: > The timeout cannot work when Emacs is stuck in a system call trying to > initiate a network connection. That is blocking, unless you use > url-retrieve asynchronously. The timeout starts working after the > connection is established, so it basically protects against too slow > downloading of data after the initial connection. That makes sense, although it's not what I would have guessed from the docstring. > I think it's a bug in Spacemacs that it attempts to solve connectivity > problems this way. What would be a reasonable alternative? This is the same approximate method used by, e.g., request.el. See https://github.com/tkf/emacs-request/blob/01e338c335c07e4407239619e57361944a82cb8a/request.el#L767-L775. Is the idea just to use url-retrieve directly? I hacked together a quick function that doesn't seem to hang: (defun url-retrieve-synchronously-but-dont-hang (url &optional silent inhibit-cookies timeout) (with-timeout (timeout (error "Timed out retrieving %S after waiting for %s seconds" url timeout)) (let* (done (buf (url-retrieve url (lambda (&rest _) (setq done (current-buffer))) nil silent inhibit-cookies))) (when buf (let ((proc (get-buffer-process buf))) (while (accept-process-output proc)) done))))) This is probably rather naive of me, but I guess now I'm wondering why url-retrieve-synchronously actually sets url-asynchronous to nil. Is there a good reason not to use :nowait when it is available? It seems like it would be useful to have a wrapper around url-retrieve that just "does what I mean" here.