mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49: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')
|
const dns = require('dns')
|
||||||
|
|
||||||
module.exports = async (data, opts) => {
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => 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 bent = require('bent')
|
||||||
const req = bent('GET')
|
const req = bent('GET')
|
||||||
|
|
||||||
module.exports = async (data, opts) => {
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => 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 req = bent('GET')
|
||||||
const E = require('../enums')
|
const E = require('../enums')
|
||||||
|
|
||||||
module.exports = async (data, opts) => {
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => 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 irc = require('irc-upd')
|
||||||
const validator = require('validator')
|
const validator = require('validator')
|
||||||
|
|
||||||
module.exports = async (data, opts) => {
|
module.exports.timeout = 20000
|
||||||
|
|
||||||
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => 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 bentReq = bent('GET')
|
||||||
const validator = require('validator')
|
const validator = require('validator')
|
||||||
|
|
||||||
module.exports = async (data, opts) => {
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => 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 bentReq = bent('GET')
|
||||||
const validator = require('validator')
|
const validator = require('validator')
|
||||||
|
|
||||||
module.exports = async (data, opts) => {
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => 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 debug = require('@xmpp/debug')
|
||||||
const validator = require('validator')
|
const validator = require('validator')
|
||||||
|
|
||||||
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
let xmpp = null,
|
let xmpp = null,
|
||||||
iqCaller = 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
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
() => reject(new Error('Request was timed out')),
|
() => reject(new Error('Request was timed out')),
|
||||||
5000
|
data.fetcherTimeout ? data.fetcherTimeout : module.exports.timeout
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue