git ssb

0+

cel-desktop / ssb-pkg



Commit 6859afcdedef7118f29d6753ba4933fb14a08f21

Retry fetching blob after ssb-ws timeout

%O8XQ2DoyhBrkFVRBOY6nX/9h2QDnFoUHk16Vl23j594=.sha256
cel 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.jschanged
prelude/install.jsView
@@ -45,22 +45,26 @@
4545 res.on('end', () => {
4646 this._makeReq()
4747 })
4848 }
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'
5256 && this.blobsBase.indexOf('localhost') > -1
5357 ) {
58 + // sometimes localhost resolves to 127.0.0.1 but ssb-ws listens on ::1
5459 this.blobsBase = this.blobsBase.replace('localhost', '[::1]')
5560 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)
5962 } else {
6063 this.destroy(err)
6164 }
62- })
65 + }
66 + this.req = http.get(url, onResp).on('error', onError)
6367 }
6468
6569 function Meter() {
6670 stream.Transform.call(this)

Built with git-ssb-web