Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async request(stanza, timeout = 30 * 1000) {
if (!stanza.attrs.id) {
stanza.attrs.id = xid()
}
const deferred = new Deferred()
this.handlers.set(stanza.attrs.id, deferred)
try {
await this.entity.send(stanza)
await timeoutPromise(deferred.promise, timeout)
} catch (err) {
this.handlers.delete(stanza.attrs.id)
throw err
}
return deferred.promise
}