mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-07 14:46:41 +00:00
chore: adjust safeCatch timeout
This commit is contained in:
parent
e1ce83efb5
commit
63841389bc
@ -4,7 +4,8 @@ import { logger } from './Logger'
|
|||||||
let c = 0
|
let c = 0
|
||||||
export const safeCatch = <TIn extends any[], TOut>(
|
export const safeCatch = <TIn extends any[], TOut>(
|
||||||
name: string,
|
name: string,
|
||||||
cb: (...args: TIn) => Promise<TOut>
|
cb: (...args: TIn) => Promise<TOut>,
|
||||||
|
timeoutMs = 5000
|
||||||
) => {
|
) => {
|
||||||
return (...args: TIn) => {
|
return (...args: TIn) => {
|
||||||
const _c = c++
|
const _c = c++
|
||||||
@ -13,8 +14,8 @@ export const safeCatch = <TIn extends any[], TOut>(
|
|||||||
const { raw, error, warn } = logger().create(pfx)
|
const { raw, error, warn } = logger().create(pfx)
|
||||||
raw(`args`, args)
|
raw(`args`, args)
|
||||||
const tid = setTimeout(() => {
|
const tid = setTimeout(() => {
|
||||||
warn(`timeout waiting for ${pfx}`)
|
error(`timeout ${timeoutMs}ms waiting for ${pfx}`)
|
||||||
}, 100)
|
}, timeoutMs)
|
||||||
|
|
||||||
return cb(...args)
|
return cb(...args)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user