Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions website/docs/en/config/dev/browser-logs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

Controls whether to forward browser runtime errors to the terminal.

When `true`, the Rsbuild client listens for window `error` events in the browser and send them to the dev server, where they are printed in the terminal (prefixed with `[browser]`).
When set to `true`, Rsbuild's client script listens for `window.error` events and unhandled Promise rejections in the browser, then sends these errors to the dev server. The server prints them in the terminal with a `[browser]` prefix, along with improved formatting and contextual information.

This feature is particularly useful when working with AI coding agents that can only read terminal output, helping them better understand runtime errors and assist in debugging.

## Example

Expand All @@ -21,7 +23,8 @@ const App = () => {
The browser will throw an error, and Rsbuild will forward this error to the terminal:

```bash
error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name') (src/App.jsx:3:0)
error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name')
(src/App.jsx:3:0)
```

## Disabling
Expand Down
7 changes: 5 additions & 2 deletions website/docs/zh/config/dev/browser-logs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

控制是否将浏览器运行时错误转发到终端。

当设置为 `true` 时,Rsbuild 的客户端会监听浏览器中的 window `error` 事件,并将它们发送到开发服务器,然后在终端中打印(带有 `[browser]` 为前缀)。
当设置为 `true` 时,Rsbuild 的客户端脚本会监听浏览器中的 `window.error` 事件,以及未捕获的 Promise 拒绝事件,并将这些错误信息发送到开发服务器。开发服务器会在终端中打印这些日志,前缀为 `[browser]`,同时带有改进的格式和上下文信息。

对于只能读取终端输出的 AI Coding Agents,这一特性有助于它们更好地理解运行时错误并协助排查问题。

## 示例

Expand All @@ -22,7 +24,8 @@ const App = () => {
浏览器会抛出错误,Rsbuild 会将此错误转发到终端:

```bash
error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name') (src/App.jsx:3:0)
error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name')
(src/App.jsx:3:0)
```

## 禁用
Expand Down
Loading