Skip to content

fix(objectstack): clean SDK client logger (no ANSI in RN/web) - #102

Merged
os-zhuang merged 1 commit into
mainfrom
fix/sdk-logger-ansi
Jun 10, 2026
Merged

fix(objectstack): clean SDK client logger (no ANSI in RN/web)#102
os-zhuang merged 1 commit into
mainfrom
fix/sdk-logger-ansi

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

What

Found during a full browser flow-test of the AI assistant: a red dev error toast showing raw ANSI escape codes[31m…ERROR[0m HTTP request failed.

The @objectstack/client SDK's default logger formats messages with terminal ANSI colour codes + timestamps. In React Native / web those escapes leak as literal [31m… text into the console and trip the dev error overlay (here, off a benign notifications 404 the example server doesn't implement).

Fix

Pass a clean logger (the SDK's ClientConfig.logger hook) to every ObjectStackClient:

  • plain console output, no ANSI;
  • debug/info silenced outside __DEV__;
  • SDK errorconsole.warn (a benign HTTP failure no longer pops the red error overlay), fatalconsole.error.

Verified

  • In the browser against a live server: the ANSI error toast is gone (Dashboard + AI screen clean).
  • npm run lint 0 errors; jest 1266/1266.

Found while testing the complete AI flow (login → connect → chat → tool call → markdown answer → conversation saved + auto-titled) end-to-end against a framework server — everything else worked well; this was the one real issue.

🤖 Generated with Claude Code

Browser flow testing surfaced a red dev error toast showing raw ANSI
escape codes: "[31m…ERROR[0m HTTP request failed". The SDK client's
default logger formats with terminal ANSI colour codes + timestamps,
which leak as literal "[31m…" text into the RN/web console and trip the
dev error overlay (notably on a benign notifications 404).

Pass a clean `logger` to every ObjectStackClient: plain console output,
no ANSI; debug/info silenced outside __DEV__; SDK `error` routed to
console.warn (so a benign HTTP failure no longer pops the red error
overlay), `fatal` stays console.error.

Verified in the browser against a live server: the ANSI error toast is
gone. Suite 1266/1266, lint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@os-zhuang
os-zhuang merged commit 1ec040b into main Jun 10, 2026
@os-zhuang
os-zhuang deleted the fix/sdk-logger-ansi branch June 10, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant