Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/homebridge-config-ui-x/node_modules/fastify/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
const {
kReplyIsError,
kReplySent,
kReplySentOverwritten
} = require('./symbols')
const { FST_ERR_PROMISE_NOT_FULFILLED } = require('./errors')
function wrapThenable (thenable, reply) {
thenable.then(function (payload) {
if (reply[kReplySentOverwritten] === true) {
return
}
// this is for async functions that
// are using reply.send directly
if (payload !== undefined || (reply.raw.statusCode === 204 && reply[kReplySent] === false)) {
// we use a try-catch internally to avoid adding a catch to another
// promise, increase promise perf by 10%
try {
reply.send(payload)
} catch (err) {
reply[kReplySent] = false
reply[kReplyIsError] = true
reply.send(err)
}
} else if (reply[kReplySent] === false) {
reply.log.error({ err: new FST_ERR_PROMISE_NOT_FULFILLED() }, "Promise may not be fulfilled with 'undefined' when statusCode is not 204")
}
}, function (err) {
if (reply[kReplySentOverwritten] === true || reply.sent === true) {
reply.log.error({ err }, 'Promise errored, but reply.sent = true was set')
return
}
reply[kReplySent] = false
reply[kReplyIsError] = true
reply.send(err)
})
}
module.exports = wrapThenable
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0046 ]-- |