Prompt
Troubleshoot frontend error not showing stack trace
Latest observation
If a frontend error is not showing a stack trace, the usual causes are:
1) Source maps are disabled or unavailable
In production builds, minified code often hides useful traces unless source maps are enabled.
Check:
- Chrome DevTools → Sources → see if
*.mapfiles load - Network tab → search for
.maprequests - Build config:
- Webpack:
devtool: 'source-map' - Vite:
build: { sourcemap: true } - Create React App: source maps usually enabled unless
GENERATE_SOURCEMAP=false
- Webpack:
Fix:
Enable source maps in the frontend build.
2) The error is being caught and swallowed
A try/catch or global error handler may be preventing the stack from appearing.
Check for:
try {
// ...
} catch (err) {
console.error(err); // or missing this
}
Fix:
Make sure the error is logged properly:
catch (err) {
console.error('Unexpected error:', err);
throw err;
}
3) Logging only error.message instead of the full error
If you log just the message, you lose the stack.
Bad:
console.error(error.message);
Better:
console.error(error);
Or:
console.error('Error:', error.stack || error);
4) Errors from async code are not handled correctly
Promise rejections and async errors may not surface like normal exceptions.
Example:
async function loadData() {
throw new Error('Failed');
}
If not awaited or caught, stack traces may not appear as expected.
Fix:
loadData().catch(err => console.error(err));
5) Framework error boundaries are masking the stack
React/Vue error handlers or boundaries may show only a generic message.
React:
Use an Error Boundary that logs the error:
componentDidCatch(error, info) {
console.error(error, info);
}
6) Browser console settings hide source locations
Some browsers collapse stack traces or hide async details.
Check:
- Console filters
- “Preserve log”
- “Async stack traces” enabled in DevTools settings
7) Production error reporting strips details
If using Sentry, Datadog, Rollbar, etc., the error may be sanitized or grouped.
Check:
- Are you capturing
error.stack? - Are source maps uploaded to the error service?
- Is stack trace symbolication enabled?
8) The error object is not a real Error
Some libraries throw plain objects or strings, which may not include stack traces.
Bad:
throw 'Something failed';
Better:
throw new Error('Something failed');
Quick debugging checklist
- Reproduce in dev mode
- Open browser console and inspect the full error object
- Verify
error.stack - Confirm source maps are enabled
- Check if any
catch/error boundary is swallowing the stack - Confirm async errors are awaited/caught
- Test in another browser/profile
If you want, I can help you troubleshoot this for a specific stack like React / Next.js / Vue / Angular / Webpack / Vite.