|
|
@ -87,10 +87,10 @@ export default class Now extends EventEmitter { |
|
|
|
}); |
|
|
|
if (this._debug) console.timeEnd('> [debug] /create'); |
|
|
|
|
|
|
|
// no retry on 403
|
|
|
|
if (403 === res.status) { |
|
|
|
// no retry on 4xx
|
|
|
|
if (400 <= res.status && 500 > res.status) { |
|
|
|
if (this._debug) { |
|
|
|
console.log('> [debug] bailing on creating due to 403'); |
|
|
|
console.log('> [debug] bailing on creating due to %s', res.status); |
|
|
|
} |
|
|
|
return bail(responseError(res)); |
|
|
|
} |
|
|
@ -140,9 +140,9 @@ export default class Now extends EventEmitter { |
|
|
|
}); |
|
|
|
if (this._debug) console.timeEnd(`> [debug] /sync ${name}`); |
|
|
|
|
|
|
|
// no retry on 403
|
|
|
|
if (403 === res.status) { |
|
|
|
if (this._debug) console.log('> [debug] bailing on creating due to 403'); |
|
|
|
// no retry on 4xx
|
|
|
|
if (400 <= res.status || 500 > res.status) { |
|
|
|
if (this._debug) console.log('> [debug] bailing on creating due to %s', res.status); |
|
|
|
return bail(responseError(res)); |
|
|
|
} |
|
|
|
|
|
|
@ -195,5 +195,13 @@ function toRelative (path, base) { |
|
|
|
function responseError (res) { |
|
|
|
const err = new Error('Response error'); |
|
|
|
err.status = res.status; |
|
|
|
|
|
|
|
if (429 === res.status) { |
|
|
|
const retryAfter = res.headers.get('Retry-After'); |
|
|
|
if (retryAfter) { |
|
|
|
err.retryAfter = parseInt(retryAfter, 10); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return err; |
|
|
|
} |
|
|
|