From cd02b0350223782fcfdfc4f0a8dc1b2c3af63102 Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Sat, 12 Sep 2026 12:50:09 +0200 Subject: [PATCH] Retry pmtiles extract/merge on failure, not just on the first try --- lib/maptool/pmtiles_builder.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/maptool/pmtiles_builder.rb b/lib/maptool/pmtiles_builder.rb index de586e8..872d9db 100644 --- a/lib/maptool/pmtiles_builder.rb +++ b/lib/maptool/pmtiles_builder.rb @@ -629,9 +629,16 @@ module Maptool end private_class_method :command_output - def self.run_pmtiles!(*args) - stdout, stderr, status = Open3.capture3(pmtiles_bin, *args) - raise BuildError, "pmtiles exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" unless status.success? + # extract/merge stream tens of GB over HTTP range requests; retry a + # transient failure (e.g. a mid-transfer HTTP/2 stream reset from the + # remote) a couple times before giving up, rather than forcing a full + # re-download on every hiccup. + def self.run_pmtiles!(*args, attempts: 3) + attempts.times do |i| + stdout, stderr, status = Open3.capture3(pmtiles_bin, *args) + return if status.success? + raise BuildError, "pmtiles exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" if i == attempts - 1 + end rescue Errno::ENOENT, Errno::EACCES => e raise BuildError, "could not run '#{pmtiles_bin}' (#{e.message}) — is go-pmtiles installed and on PATH? See docs/development.adoc." end