-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Description
Currently, when errors occur in the bundled JavaScript, it's difficult to trace them back to the original TypeScript source files. This makes debugging complex issues challenging, especially when they occur in production builds.
Problem
A recent example of this difficulty was encountered with the following error stack trace:
index.js:41 Error: Bad substitution: {
at H (index.js:1642:33775)
at index.js:1642:34347
at Array.map (<anonymous>)
at b (index.js:1642:33515)
at Object.$R [as parse] (index.js:1642:34484)
at kbt (index.js:1642:35235)
at _bt (index.js:1642:35957)
at index.js:2361:28912
at index.js:2361:29257
at index.js:2361:22928Without source maps, it's nearly impossible to determine which original source files and functions are involved in this error.
This specific error was fixed in issue #3529, but the debugging process was extremely difficult without proper source maps. With source maps enabled, identifying and fixing similar issues in the future will be much more straightforward.
Proposed Solution
Enable source maps in the webview UI build process by:
- Adding sourceMap: true to tsconfig.json
- Setting inlineSources: false in tsconfig.json
- Enabling sourcemap: true in vite.config.ts
- Adding source-map package as a dependency
This will allow stack traces to be mapped back to the original TypeScript source files, making debugging significantly easier. For example, the above stack trace would be transformed to something like:
Error: Bad substitution: {
at parseEnvVar (node_modules/shell-quote/parse.js:128:11)
at parseCommand (src/utils/command-validation.ts:42:15)
at Array.map (<anonymous>)
at tokenizeCommand (node_modules/shell-quote/parse.js:85:22)
at Object.parse (node_modules/shell-quote/parse.js:156:18)
at validateCommand (src/utils/command-validation.ts:112:34)
at isAllowedCommand (src/components/chat/ChatView.tsx:736:7)
at isAutoApproved (src/components/chat/ChatView.tsx:766:42)
at handleMessageApproval (src/components/chat/ChatView.tsx:924:15)
at processMessage (src/components/chat/ChatView.tsx:1088:22)Note
While these changes could increase the size of the deployment package, they provide incredibly useful debugging information for users that find bugs, especially those that crash the application. The ability to trace errors back to the original source code is invaluable for troubleshooting complex issues.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status