From: Tobias Geerinckx-Rice <me@tobias.gr>
To: 26489@debbugs.gnu.org
Subject: bug#26489: [PATCH] substitute: Ignore bad responses.
Date: Fri, 14 Apr 2017 02:27:55 +0200 [thread overview]
Message-ID: <20170414002755.32672-1-me@tobias.gr> (raw)
* guix/scripts/substitute.scm (http-multiple-get): Catch BAD-RESPONSE
exceptions and keep going.
---
Guix,
One weird HTTP response from a server will kill ‘guix substitute’:
updating list of substitutes from 'https://foo'... 50.0%Backtrace:
...
guix/ui.scm:1229:8: In procedure run-guix-command:
guix/ui.scm:1229:8: Throw to key `bad-response' with args
`("Bad Response-Line: ~s" (""))'.
error: build failed: substituter `substitute' died unexpectedly
Attached is a patch to ignore such bad responses. The offending .narinfo
will be ignored for that session, and not cached at all. The result:
updating list of substitutes from 'https://bar'... 100.0%
updating list of substitutes from 'https://foo'... 2.9% (bad response)
updating list of substitutes from 'https://foo'... 5.9% (bad response)
As a nice bonus, guix doesn't keel over and die.
Is this the best solution? A good one? Should it be made more obvious
that only READ-RESPONSE can throw, and that PROC will never be called
with, a bad response? No idea. I haven't had enough free time to learn
good the Guile like I'd so hoped to do at the beginning of the year. :c
Be gentle, dear reader, and all that,
T G-R
guix/scripts/substitute.scm | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index d3bccf4dd..7eccf9831 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -564,18 +564,24 @@ initial connection on which HTTP requests are sent."
(()
(reverse result))
((head tail ...)
- (let* ((resp (read-response p))
- (body (response-body-port resp))
- (result (proc head resp body result)))
- ;; The server can choose to stop responding at any time, in which
- ;; case we have to try again. Check whether that is the case.
- ;; Note that even upon "Connection: close", we can read from BODY.
- (match (assq 'connection (response-headers resp))
- (('connection 'close)
- (close-connection p)
- (connect #f tail result)) ;try again
- (_
- (loop tail result)))))))))) ;keep going
+ (catch 'bad-response
+ (lambda ()
+ (let* ((resp (read-response p))
+ (body (response-body-port resp))
+ (result (proc head resp body result)))
+ ;; The server can stop responding at any time, in which case
+ ;; we have to try again. Check whether that's the case. Note
+ ;; that we can read from BODY even upon "Connection: close".
+ (match (assq 'connection (response-headers resp))
+ (('connection 'close)
+ (close-connection p)
+ (connect #f tail result)) ; try again
+ (_
+ (loop tail result))))) ; keep going
+ (lambda args
+ ;; This message appears on the same line as the progress report.
+ (format (current-error-port) " (bad response)~%")
+ (loop tail result))))))))) ; keep going
(define (read-to-eof port)
"Read from PORT until EOF is reached. The data are discarded."
--
2.12.2
next reply other threads:[~2017-04-14 0:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-14 0:27 Tobias Geerinckx-Rice [this message]
2017-04-14 9:54 ` bug#26489: [PATCH] substitute: Ignore bad responses Ludovic Courtès
2017-04-28 20:56 ` Tobias Geerinckx-Rice
2017-05-01 13:14 ` Ludovic Courtès
2020-12-18 20:19 ` [bug#26489] " zimoun
2020-12-20 13:39 ` Ludovic Courtès
2021-01-11 13:08 ` zimoun
2021-01-15 19:52 ` Julien Lepiller
2021-02-09 1:05 ` zimoun
2021-02-09 8:42 ` bug#26489: " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170414002755.32672-1-me@tobias.gr \
--to=me@tobias.gr \
--cc=26489@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.