mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Improve handling of request timeout
This commit is contained in:
parent
be258abf93
commit
2bf92ff9df
7 changed files with 28 additions and 14 deletions
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue