Set default timeout of 20s for HTTP calls (#18549)

pull/18614/head
Rodrigo Nascimento 5 years ago committed by GitHub
parent 0e2309efc3
commit 0a2d8ca16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/rocketchat-mongo-config/package.js
  2. 12
      packages/rocketchat-mongo-config/server/index.js

@ -10,6 +10,7 @@ Package.onUse(function(api) {
'ecmascript',
'mongo',
'email',
'http',
]);
api.mainModule('server/index.js', 'server');

@ -3,6 +3,18 @@ import { PassThrough } from 'stream';
import { EmailTest } from 'meteor/email';
import { Mongo } from 'meteor/mongo';
import { HTTP } from 'meteor/http';
// Set default HTTP call timeout to 20s
const envTimeout = parseInt(process.env.HTTP_DEFAULT_TIMEOUT, 10);
const timeout = !isNaN(envTimeout) ? envTimeout : 20000;
const { call } = HTTP;
HTTP.call = function _call(method, url, options = {}, callback) {
const defaultTimeout = 'timeout' in options ? options : { ...options, timeout };
return call.call(HTTP, method, url, defaultTimeout, callback);
};
// FIX For TLS error see more here https://github.com/RocketChat/Rocket.Chat/issues/9316
// TODO: Remove after NodeJS fix it, more information

Loading…
Cancel
Save