mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix maximum call stack size error
This commit is contained in:
parent
163dbc73a6
commit
6acedb64c8
1 changed files with 9 additions and 4 deletions
|
|
@ -97,18 +97,23 @@ function localConfig(id: string): ConsoleTransportOptions {
|
|||
const truncateObjectDeep = (object: any, length: number): any => {
|
||||
const copyObj = cloneDeep(object) as never
|
||||
|
||||
const truncateDeep = (obj: any): any => {
|
||||
const truncateDeep = (obj: any, level: number): any => {
|
||||
// reach maximum call stack size
|
||||
if (level >= 6) {
|
||||
return obj
|
||||
}
|
||||
|
||||
if (isString(obj) && obj.length > length) {
|
||||
return `${truncate(obj, { length })} [truncated]`
|
||||
}
|
||||
|
||||
if (isArray(obj)) {
|
||||
return obj.map((i) => truncateDeep(i) as never)
|
||||
return obj.map((i) => truncateDeep(i, level + 1) as never)
|
||||
}
|
||||
|
||||
if (isObject(obj)) {
|
||||
Object.entries(obj).forEach(([key, value]) => {
|
||||
obj[key as keyof typeof obj] = truncateDeep(value) as never
|
||||
obj[key as keyof typeof obj] = truncateDeep(value, level + 1) as never
|
||||
})
|
||||
|
||||
return obj
|
||||
|
|
@ -118,7 +123,7 @@ const truncateObjectDeep = (object: any, length: number): any => {
|
|||
return obj
|
||||
}
|
||||
|
||||
return truncateDeep(copyObj)
|
||||
return truncateDeep(copyObj, 1)
|
||||
}
|
||||
|
||||
class GcpLoggingTransport extends LoggingWinston {
|
||||
|
|
|
|||
Loading…
Reference in a new issue