From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 2ATaIOt7T2AABAAA0tVLHw (envelope-from ) for ; Mon, 15 Mar 2021 15:23:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wJqwHOt7T2CkVAAA1q6Kng (envelope-from ) for ; Mon, 15 Mar 2021 15:23:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1869016C28 for ; Mon, 15 Mar 2021 16:23:22 +0100 (CET) Received: from localhost ([::1]:52548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLp3w-0008Ie-OP for larch@yhetil.org; Mon, 15 Mar 2021 11:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLp1i-0006Pf-I3 for guix-patches@gnu.org; Mon, 15 Mar 2021 11:21:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLp1i-0000Qq-92 for guix-patches@gnu.org; Mon, 15 Mar 2021 11:21:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lLp1i-00066V-5V for guix-patches@gnu.org; Mon, 15 Mar 2021 11:21:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47160] [PATCH] scripts: substitute: Add back some error handling. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 15 Mar 2021 15:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47160 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 47160@debbugs.gnu.org Received: via spool by 47160-submit@debbugs.gnu.org id=B47160.161582165623426 (code B ref 47160); Mon, 15 Mar 2021 15:21:02 +0000 Received: (at 47160) by debbugs.gnu.org; 15 Mar 2021 15:20:56 +0000 Received: from localhost ([127.0.0.1]:36388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLp1c-00065m-0X for submit@debbugs.gnu.org; Mon, 15 Mar 2021 11:20:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLp1a-00065X-Co for 47160@debbugs.gnu.org; Mon, 15 Mar 2021 11:20:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43885) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLp1T-0000Nd-Px; Mon, 15 Mar 2021 11:20:47 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=46140 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lLp1R-0003kC-Vv; Mon, 15 Mar 2021 11:20:47 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210315151133.16282-1-mail@cbaines.net> Date: Mon, 15 Mar 2021 16:20:43 +0100 In-Reply-To: <20210315151133.16282-1-mail@cbaines.net> (Christopher Baines's message of "Mon, 15 Mar 2021 15:11:33 +0000") Message-ID: <8735wwh29g.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1615821802; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=Ix1ZBokjN4eYAETUk38meleB9od+58ATJArWwR6IkC4=; b=mNIy1wZ5WVUsyj8423m4ispvkHrZJJnEeJ29oS4nZhfsWo+OIqh3ITT8fLD4H1Dzmx+/0/ Zo1yclD0LowGysftjLklTUcN1WHdCOyBCLhHDKpwQujY6DMVqc3fgch/l+ZrYEeGB7K2C7 NaCveO/kB6mZMRz4Cwx2G3ivUE5rDy1DL4iYuY6Ta2UFNbYgSliQpicMzWRna27DEJMbmT 5uimRzAp+AGXijfSEdEsQqzAO9rsKcErxafbka3eKaV1WnzZIX2iuD3giUyMSl9NyT2y8j qtEqHXB3w0JTh9VyKbs+T96JFoqdj6ezeHU/3AgCaw7t1HR+26ftVx0KQeXfJg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615821802; a=rsa-sha256; cv=none; b=l8xDZqCv4ioReWUWu/bxPDe9wWHOp5bhrYAbvJv09hAJ5byBQZnI4vJrZ4nxP/6IB9RmEQ Oxdx3matY9oRyLQsIAnbbuhQDw283iNDJfLFVifWohiA1CzMzau9h1l7hXUNm37fJcFlnr 7SGvGht4UW8/uC24ewTHVdJIADYlPQ/yvDPZJFvtNZxR+F8ysnnKcsCwdR/pYvUEkTgAUM 9A+tmaK1piqAYWuVBjR6v4FlamHmawkoqHHzZvwxw/9D9cS0OggQRbWtmDauN+b8SvEErl 0grJge76Y3b8ZRNdfDgDl0CjNfzSm4sLpWzFZQGOg+tS5ug3dgU9B74Cj6v55Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.40 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 1869016C28 X-Spam-Score: -1.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: OoDRkAjzI/N/ Hi, Christopher Baines skribis: > In f50f5751fff4cfc6d5abba9681054569694b7a5c, the way fetch was called wit= hin > process-substitution was changed. As with-cached-connection actually inc= ludes > important error handling for the opening of a HTTP request (when using a > cached connection), this change removed some error handling. > > This commit adds that error handling back, > with-cached-connection/call-with-cached-connection is back, rebranded as > call-with-fresh-connection-retry. > > * guix/scripts/substitute.scm (process-substitution): Retry once for some > errors when making HTTP requests to fetch substitutes. [...] > + (define (call-with-fresh-connection-retry uri proc) > + (define (get-port) > + (open-connection-for-uri/cached uri > + #:verify-certificate? #f)) > + > + (let ((port (get-port))) > + (catch #t > + (lambda () > + (proc port)) > + (lambda (key . args) > + ;; If PORT was cached and the server closed the connection in = the > + ;; meantime, we get EPIPE. In that case, open a fresh connect= ion > + ;; and retry. We might also get 'bad-response or a similar > + ;; exception from (web response) later on, once we've sent the > + ;; request, or a ERROR/INVALID-SESSION from GnuTLS. > + (if (or (and (eq? key 'system-error) > + (=3D EPIPE (system-error-errno `(,key ,@args)))) > + (and (eq? key 'gnutls-error) > + (eq? (first args) error/invalid-session)) > + (memq key '(bad-response bad-header bad-header-compone= nt))) > + (begin > + (close-port port) ; close the port to get a fresh = one > + (proc (get-port))) > + (apply throw key args)))))) I think this should be at the top level for clarity. It used to have =E2=80=98cached=E2=80=99 in its name because catching all these exceptions = is something you wouldn=E2=80=99t normally do; it only makes sense in the context of cac= hed connections. > (define (fetch uri) > (case (uri-scheme uri) > ((file) > @@ -424,11 +450,13 @@ the current output port." > (call-with-connection-error-handling > uri > (lambda () > - (http-fetch uri #:text? #f > - #:open-connection open-connection-for-uri/cach= ed > - #:keep-alive? #t > - #:buffered? #f > - #:verify-certificate? #f)))))) > + (call-with-fresh-connection-retry > + uri > + (lambda (port) > + (http-fetch uri #:text? #f > + #:port port > + #:keep-alive? #t > + #:buffered? #f)))))))) Does =E2=80=98call-with-connection-error-handling=E2=80=99 still make sense= here? There=E2=80=99s already =E2=80=98with-networking=E2=80=99 at the top level = to do proper networking error reporting. Regarding , I would lean towards perhaps reverting the connection/error-handling patch series and starting anew from that =E2=80=9Cknown state=E2=80=9D. This area is unfortunately quite tedious to test and to get right so I=E2= =80=99d err on the path of conservative, incremental changes. Thought? Ludo=E2=80=99.