type BrowserLogs =
| boolean
| {
stackTrace?: 'summary' | 'full' | 'none';
};{ stackTrace: 'summary' }Controls whether to forward browser runtime errors to the terminal.
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.
For example, if you have the following code in your application:
const App = () => {
const item = undefined;
return <div>{item.name}</div>;
};The browser will throw an error, and Rsbuild will forward this error to the terminal:
error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at handleClick (src/App.jsx:3:0)'summary' | 'full' | 'none''summary'Controls how the error stack trace is displayed in the terminal when forwarding browser errors.
'summary' – Show only the first frame (e.g. (src/App.jsx:3:0)).'full' – Print the full stack trace with all frames.'none' – Hide stack traces.For example, setting stackTrace to 'full':
export default {
dev: {
browserLogs: {
stackTrace: 'full',
},
},
};The full stack trace will be like:
error [browser] Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at handleClick (src/App.jsx:6:0)
at someFunction (src/App.jsx:12:0)
at App (src/App.jsx:6:0)
...Set dev.browserLogs to false to disable this behavior.
export default {
dev: {
browserLogs: false,
},
};| Version | Changes |
|---|---|
| v1.5.13 | Added this option |
| v1.6.0 | Added stackTrace option |