diff --git a/website/docs/en/config/dev/browser-logs.mdx b/website/docs/en/config/dev/browser-logs.mdx index 62d145c464..ddf7eb9a42 100644 --- a/website/docs/en/config/dev/browser-logs.mdx +++ b/website/docs/en/config/dev/browser-logs.mdx @@ -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 @@ -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 diff --git a/website/docs/zh/config/dev/browser-logs.mdx b/website/docs/zh/config/dev/browser-logs.mdx index a44368107f..8290657c0a 100644 --- a/website/docs/zh/config/dev/browser-logs.mdx +++ b/website/docs/zh/config/dev/browser-logs.mdx @@ -6,7 +6,9 @@ 控制是否将浏览器运行时错误转发到终端。 -当设置为 `true` 时,Rsbuild 的客户端会监听浏览器中的 window `error` 事件,并将它们发送到开发服务器,然后在终端中打印(带有 `[browser]` 为前缀)。 +当设置为 `true` 时,Rsbuild 的客户端脚本会监听浏览器中的 `window.error` 事件,以及未捕获的 Promise 拒绝事件,并将这些错误信息发送到开发服务器。开发服务器会在终端中打印这些日志,前缀为 `[browser]`,同时带有改进的格式和上下文信息。 + +对于只能读取终端输出的 AI Coding Agents,这一特性有助于它们更好地理解运行时错误并协助排查问题。 ## 示例 @@ -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) ``` ## 禁用