Commit 6859afcdedef7118f29d6753ba4933fb14a08f21
Retry fetching blob after ssb-ws timeout
%O8XQ2DoyhBrkFVRBOY6nX/9h2QDnFoUHk16Vl23j594=.sha256cel authored on 7/10/2020, 6:45:11 PM
Charles E. Lehner committed on 9/2/2020, 12:55:02 AM
Parent: c5c7a8ffadbd51aa28a5f3f096fe43f69405da44
Files changed
prelude/install.js | changed |
prelude/install.js | ||
---|---|---|
@@ -45,22 +45,26 @@ | ||
45 | 45 … | res.on('end', () => { |
46 | 46 … | this._makeReq() |
47 | 47 … | }) |
48 | 48 … | } |
49 | - this.req = http.get(url, onResp).on('error', (err) => { | |
50 | - // sometimes localhost resolves to 127.0.0.1 but ssb-ws listens on ::1 | |
51 | - if (err.code === 'ECONNREFUSED' && err.address === '127.0.0.1' | |
49 … | + var onError = (err) => { | |
50 … | + if (err.code === 'ECONNRESET') { | |
51 … | + // retry after timeout | |
52 … | + setTimeout(() => { | |
53 … | + this.req = http.get(url, onResp).on('error', onError) | |
54 … | + }, 1e3) | |
55 … | + } else if (err.code === 'ECONNREFUSED' && err.address === '127.0.0.1' | |
52 | 56 … | && this.blobsBase.indexOf('localhost') > -1 |
53 | 57 … | ) { |
58 … | + // sometimes localhost resolves to 127.0.0.1 but ssb-ws listens on ::1 | |
54 | 59 … | this.blobsBase = this.blobsBase.replace('localhost', '[::1]') |
55 | 60 … | url = this.blobsBase + id |
56 | - http.get(url, onResp).on('error', (err) => { | |
57 | - this.destroy(err) | |
58 | - }) | |
61 … | + http.get(url, onResp).on('error', onError) | |
59 | 62 … | } else { |
60 | 63 … | this.destroy(err) |
61 | 64 … | } |
62 | - }) | |
65 … | + } | |
66 … | + this.req = http.get(url, onResp).on('error', onError) | |
63 | 67 … | } |
64 | 68 … | |
65 | 69 … | function Meter() { |
66 | 70 … | stream.Transform.call(this) |
Built with git-ssb-web