retry-request
Advanced tools
Comparing version 2.0.4 to 2.0.5
28
index.js
'use strict'; | ||
var firstEvent = require('first-event'); | ||
var request = require('request'); | ||
@@ -43,2 +42,3 @@ var through = require('through2'); | ||
var numNoResponseAttempts = 0; | ||
var streamResponseHandled = false; | ||
@@ -90,11 +90,27 @@ var retryStream; | ||
if (streamMode) { | ||
streamResponseHandled = false; | ||
delayStream = through({ objectMode: opts.objectMode }); | ||
requestStream = opts.request(requestOpts); | ||
firstEvent(requestStream, ['error', 'response']) | ||
.then(resp => onResponse.apply(null, [null].concat(resp.args))) | ||
.catch(onResponse); | ||
requestStream | ||
// gRPC via google-cloud-node can emit an `error` as well as a `response` | ||
// Whichever it emits, we run with-- we can't run with both. That's what | ||
// is up with the `streamResponseHandled` tracking. | ||
.on('error', function(err) { | ||
if (streamResponseHandled) { | ||
return; | ||
} | ||
requestStream | ||
.on('error', function() {}) // Cannot remove. Node internals get confused: https://github.com/stephenplusplus/retry-request/pull/11#discussion_r118394078 | ||
streamResponseHandled = true; | ||
onResponse(err); | ||
}) | ||
.on('response', function(resp, body) { | ||
if (streamResponseHandled) { | ||
return; | ||
} | ||
streamResponseHandled = true; | ||
onResponse(null, resp, body); | ||
}) | ||
.on('complete', retryStream.emit.bind(retryStream, 'complete')); | ||
@@ -101,0 +117,0 @@ |
{ | ||
"name": "retry-request", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Retry a request.", | ||
@@ -25,3 +25,2 @@ "main": "index.js", | ||
"dependencies": { | ||
"first-event": "^1.0.0", | ||
"request": "^2.81.0", | ||
@@ -28,0 +27,0 @@ "through2": "^2.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8633
2
138
- Removedfirst-event@^1.0.0
- Removed101@1.6.3(transitive)
- Removedassert-args@1.2.1(transitive)
- Removedclone@1.0.4(transitive)
- Removedcompound-subject@0.0.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddeep-eql@0.1.3(transitive)
- Removedfirst-event@1.0.0(transitive)
- Removedget-prototype-of@0.0.0(transitive)
- Removedis-capitalized@1.0.0(transitive)
- Removedis-class@0.0.4(transitive)
- Removedkeypather@1.10.2(transitive)
- Removedms@2.0.0(transitive)
- Removedtype-detect@0.1.1(transitive)