fix: Unexpected TypeError in GatewayManager.requestMembers (#4197)

* fix: Unexpected TypeError in `GatewayManager.requestMembers` debug message

closes #4196

* refactor: prefer JSON.stringify replacer parameter when serializing

* Order functions in utils.ts
This commit is contained in:
Max Zargov
2025-05-24 08:19:51 +02:00
committed by GitHub
parent cafc5713ab
commit dff9df5a59
3 changed files with 23 additions and 3 deletions
+11
View File
@@ -14,3 +14,14 @@ export async function delay(ms: number): Promise<void> {
export function hasProperty<T extends {}, Y extends PropertyKey = string>(obj: T, prop: Y): obj is T & Record<Y, unknown> {
return obj.hasOwnProperty(prop)
}
/** Convert `JSON.stringify`-unserializable record values for debugging purposes. */
export function jsonSafeReplacer(_key: string, value: unknown): unknown {
switch (typeof value) {
case 'bigint':
// Bigints are unserializable by `JSON.stringify`.
return String(value)
default: // Any other unhandled type that isn't supposed to require conversion.
return value
}
}