You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a bug when I import mailgun-js and gocardless-nodejs libs in the same project.
Here is the error message I got:
(node:62883) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
at Api.isIdempotencyConflict (/Users/johndoe/Github/johndoe-admin/node_modules/gocardless-nodejs/api/api.js:125:26)
at Api.request (/Users/johndoe/Github/johndoe-admin/node_modules/gocardless-nodejs/api/api.js:58:22)
(node:62883) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:62883) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
You need to install 3 libs to reproduce the problem:
npm i mailgun-js gocardless-nodejs cuid
Here is the full code you can use (don't forget to add your GoCardless PRIVATE_API_KEY):
After looking into this it looks like mailgun-js is using an old version of agent-base (version 4) which is monkey patching https (https://github.com/TooTallNate/node-agent-base/blob/4.3.0/patch-core.js) and this is causing the issue. Any https call that is made will fail, see below example:
var got = require('got');
var mailgun = require('mailgun-js');
(async () => {
var httpWorking = await got('http://www.google.co.uk');
console.log(httpWorking);
var httpsNotWorking = await got('https://www.google.co.uk');
console.log(httpsNotWorking);
})();
This bug/issue is fixed in agent-base version 5 and above. I'd reach out to the authors of the mailgun-js library and see if they can update their dependencies.
I ran into a bug when I import
mailgun-js
andgocardless-nodejs
libs in the same project.Here is the error message I got:
You need to install 3 libs to reproduce the problem:
npm i mailgun-js gocardless-nodejs cuid
Here is the full code you can use (don't forget to add your GoCardless PRIVATE_API_KEY):
It might be an error with the
got
lib GoCardless uses.The text was updated successfully, but these errors were encountered: