I am getting this issue too, but only if I configured npm run dev with nodemon.
After tracing the issue, it was related to the fact that Im using a ngrok free account, which allows me to open a single ngrok tunnel.
Then, when the server is automatically restarted (for instance, when I updated my code and saved my code file), somehow node_modules/atlassian-connect-express/lib/internal/registration/register-jira-conf.js
from ACE is not killing the first ngrok instance.
Hence, ngrok tries to open 127.0.0.1:4041 instead of 127.0.0.1:4040, which will fail for the cause previously mentioned (ngrok free account).
It all went to this function of the ACE code:
...
function requireNgrok() {
return require('../require-optional').requireOptional('ngrok');
}
....
exports.deregister = function () {
....
promise.finally(function () {
requireNgrok().then(function (ngrok) {
console.log('IT NEVER GETS HERE')
ngrok.kill();
});
});
Then, if I check this file node_modules/atlassian-connect-express/lib/internal/require-optional.js
exports.requireOptional = function requireOptional(moduleName) {
return new RSVP.Promise(function (resolve, reject) {
try {
resolve(require(moduleName));
console.log('IT RESOLVES THIS MODULE CORRECTLY')
} catch (err) {
reject(err);
}
});
};
So, somehow requireNgrok()
function is not resolving the ngrok module correctly when deregistering and then it never kills ngrok.
In the other hand, a very similar code works fine in the same register-jira-conf.js
file in the createTunnel
function.
Does anyone have any ideas? For me, it’s a clear bug from ACE, but not sure if it’s related to a bug in RSVP too.
PD: Im using MacOS Catalina Version 10.15.5 and
“atlassian-connect-express”: “^3.5.0”,
“devDependencies”: {
“eslint”: “^5.16.0”,
“ngrok”: “^3.3.0”,
“nodemon”: “^1.19.4”,
“sqlite3”: “^4.2.0”
}
However, I see that ACE 3.5.0 is using "ngrok": "^3.2.4"
and "rsvp": "^4.8.5"
instead. Not sure if that’s related
Thanks