diff --git a/src/fetcher/dns.js b/src/fetcher/dns.js index a2fd886..8e4cd35 100644 --- a/src/fetcher/dns.js +++ b/src/fetcher/dns.js @@ -15,12 +15,14 @@ limitations under the License. */ const dns = require('dns') -module.exports = async (data, opts) => { +module.exports.timeout = 5000 + +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 5000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) }) diff --git a/src/fetcher/gitlab.js b/src/fetcher/gitlab.js index 0a3edd3..764e8b5 100644 --- a/src/fetcher/gitlab.js +++ b/src/fetcher/gitlab.js @@ -16,12 +16,14 @@ limitations under the License. const bent = require('bent') const req = bent('GET') -module.exports = async (data, opts) => { +module.exports.timeout = 5000 + +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 5000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) }) diff --git a/src/fetcher/http.js b/src/fetcher/http.js index 72db0e1..985765f 100644 --- a/src/fetcher/http.js +++ b/src/fetcher/http.js @@ -17,12 +17,14 @@ const bent = require('bent') const req = bent('GET') const E = require('../enums') -module.exports = async (data, opts) => { +module.exports.timeout = 5000 + +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 5000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) }) diff --git a/src/fetcher/irc.js b/src/fetcher/irc.js index 7860e9e..7a05834 100644 --- a/src/fetcher/irc.js +++ b/src/fetcher/irc.js @@ -16,12 +16,14 @@ limitations under the License. const irc = require('irc-upd') const validator = require('validator') -module.exports = async (data, opts) => { +module.exports.timeout = 20000 + +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 20000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) }) diff --git a/src/fetcher/matrix.js b/src/fetcher/matrix.js index 0d6454c..c20e681 100644 --- a/src/fetcher/matrix.js +++ b/src/fetcher/matrix.js @@ -17,12 +17,14 @@ const bent = require('bent') const bentReq = bent('GET') const validator = require('validator') -module.exports = async (data, opts) => { +module.exports.timeout = 5000 + +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 5000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) }) diff --git a/src/fetcher/twitter.js b/src/fetcher/twitter.js index 569f50a..89479ae 100644 --- a/src/fetcher/twitter.js +++ b/src/fetcher/twitter.js @@ -17,12 +17,14 @@ const bent = require('bent') const bentReq = bent('GET') const validator = require('validator') -module.exports = async (data, opts) => { +module.exports.timeout = 5000 + +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 5000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) }) diff --git a/src/fetcher/xmpp.js b/src/fetcher/xmpp.js index 2e9fe85..c432881 100644 --- a/src/fetcher/xmpp.js +++ b/src/fetcher/xmpp.js @@ -18,6 +18,8 @@ const { client, xml } = require('@xmpp/client') const debug = require('@xmpp/debug') const validator = require('validator') +module.exports.timeout = 5000 + let xmpp = null, iqCaller = null @@ -43,12 +45,12 @@ const xmppStart = async (service, username, password) => { }) } -module.exports = async (data, opts) => { +module.exports.fn = async (data, opts) => { let timeoutHandle const timeoutPromise = new Promise((resolve, reject) => { timeoutHandle = setTimeout( () => reject(new Error('Request was timed out')), - 5000 + data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout ) })