Skip to content

Commit 1940c7c

Browse files
committed
fix: silence fallback.ts console.error, complete terminal distortion fix, bump v0.9.10
1 parent 0338596 commit 1940c7c

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.9.10 (2026-03-29)
4+
5+
### Bug Fixes
6+
7+
- **Terminal distortion (complete fix)**: `fallback.ts` was still using `console.error` for network error messages (e.g., `[fallback] anthropic/claude-sonnet-4.6 network error: fetch failed`), which printed to stderr — also inherited by Claude Code's terminal. All fallback error messages now go to the log file only. Combined with v0.9.9, brcc is now fully silent while Claude Code is running
8+
39
## 0.9.9 (2026-03-28)
410

511
### Bug Fixes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blockrun/cc",
3-
"version": "0.9.9",
3+
"version": "0.9.10",
44
"description": "Run Claude Code with any model — no rate limits, no account locks, no phone verification. Pay per use with USDC.",
55
"type": "module",
66
"bin": {

src/proxy/fallback.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
* Automatically switches to backup models when primary fails (429, 5xx, etc.)
44
*/
55

6+
import fs from 'node:fs';
7+
import os from 'node:os';
8+
import path from 'node:path';
9+
10+
const LOG_FILE = path.join(os.homedir(), '.blockrun', 'brcc-debug.log');
11+
12+
// eslint-disable-next-line no-control-regex
13+
const ANSI_RE = /\x1B\[[0-9;]*[A-Za-z]|\x1B\][^\x07]*\x07|\x1B[()][A-B]|\r/g;
14+
function appendLog(msg: string) {
15+
try {
16+
fs.mkdirSync(path.dirname(LOG_FILE), { recursive: true });
17+
fs.appendFileSync(LOG_FILE, `[${new Date().toISOString()}] ${msg.replace(ANSI_RE, '')}\n`);
18+
} catch { /* ignore */ }
19+
}
20+
621
export interface FallbackConfig {
722
/** Models to try in order of priority */
823
chain: string[];
@@ -111,7 +126,7 @@ export async function fetchWithFallback(
111126
if (nextModel && onFallback) {
112127
const errMsg = err instanceof Error ? err.message : 'Network error';
113128
onFallback(model, 0, nextModel);
114-
console.error(`[fallback] ${model} network error: ${errMsg}`);
129+
appendLog(`[brcc] [fallback] ${model} network error: ${errMsg}`);
115130
}
116131

117132
if (i < config.chain.length - 1) {

0 commit comments

Comments
 (0)