π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: safe stringify
Nevo Davidd7a92e0b926f
diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.tsindex 150d642a9..4d96e6056 100644--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts@@ -30,6 +30,20 @@ export class NotEnoughScopes {constructor(public message = 'Not enough scopes') {}}+function safeStringify(obj: any) {+ const seen = new WeakSet();++ return JSON.stringify(obj, (key, value) => {+ if (typeof value === 'object' && value !== null) {+ if (seen.has(value)) {+ return '[Circular]';+ }+ seen.add(value);+ }+ return value;+ });+}+export abstract class SocialAbstract {abstract identifier: string;maxConcurrentJob = 1;@@ -62,7 +76,7 @@ export abstract class SocialAbstract {try {value = await func();} catch (err) {- const handle = this.handleErrors(JSON.stringify(err));+ const handle = this.handleErrors(safeStringify(err));value = { err: true, value: 'Unknown Error', ...(handle || {}) };}@@ -70,12 +84,12 @@ export abstract class SocialAbstract {if (value.type === 'refresh-token') {throw new RefreshToken('',- JSON.stringify({}),+ safeStringify({}),{} as any,value.value || '');}- throw new BadBody('', JSON.stringify({}), {} as any, value.value || '');+ throw new BadBody('', safeStringify({}), {} as any, value.value || '');}return value;