wasp/waspc/data/Generator/templates/server/patches/oauth+0.9.15.patch
2022-09-06 14:35:59 -04:00

22 lines
946 B
Diff

diff --git a/node_modules/oauth/lib/oauth2.js b/node_modules/oauth/lib/oauth2.js
index 77241c4..b6c0184 100644
--- a/node_modules/oauth/lib/oauth2.js
+++ b/node_modules/oauth/lib/oauth2.js
@@ -158,8 +158,14 @@ exports.OAuth2.prototype._executeRequest= function( http_library, options, post_
});
});
request.on('error', function(e) {
- callbackCalled= true;
- callback(e);
+ // Ref: https://github.com/ciaranj/node-oauth/pull/363
+ // `www.googleapis.com` does `ECONNRESET` just after data is received in `passBackControl`
+ // this prevents the callback from being called twice, first in passBackControl and second time in here
+ // see also NodeJS Stream documentation: "The 'error' event may be emitted by a Readable implementation at any time"
+ if(!callbackCalled) {
+ callbackCalled= true;
+ callback(e);
+ }
});
if( (options.method == 'POST' || options.method == 'PUT') && post_body ) {