Master stack trace analysis to quickly identify and fix JavaScript errors in your application.
Understanding Stack Traces
Anatomy of a Stack Trace
TypeError: Cannot read property 'email' of undefined
at getUserEmail (user-service.js:45:12) ← Error location
at validateForm (form-handler.js:123:8) ← Called from here
at HTMLFormElement.<anonymous> (form.js:67:5) ← Event handler
at HTMLFormElement.dispatch (jquery.min.js:3:10456)
at HTMLFormElement.v.handle (jquery.min.js:3:8765)
Stack Frame Components
Each line contains:
| Component | Example | Description |
|---|---|---|
| Function | getUserEmail | Function name |
| File | user-service.js | Source file |
| Line | 45 | Line number |
| Column | 12 | Column position |
Reading Direction
Read stack traces top to bottom:
- Top frame: Where error occurred
- Middle frames: Call chain
- Bottom frames: Entry point
Stack Trace Viewer
Full Stack View
In the error detail page:
Error: User not found
► user-service.js:45:12 - getUserById
43 | async function getUserById(id) {
44 | const user = await db.users.find(id);
→ 45 | if (!user) throw new Error('User not found');
46 | return user;
47 | }
► api-handler.js:78:5 - handleGetUser
76 | async function handleGetUser(req, res) {
77 | const userId = req.params.id;
→ 78 | const user = await getUserById(userId);
79 | res.json(user);
80 | }
► router.js:23:3 - <anonymous>
Frame Navigation
- Click frame: Expand/collapse source preview
- Copy: Copy stack trace text
- Open in editor: Open file in configured IDE
Source Context
For each frame, see:
- 3 lines before error
- Error line (highlighted)
- 3 lines after error
- Variable values (when available)
Source Maps
Without Source Maps
Minified code produces cryptic traces:
TypeError: a is not a function
at e (main.abc123.js:1:34567)
at t.handleClick (main.abc123.js:1:45678)
at Object.onClick (main.abc123.js:1:56789)
With Source Maps
Same error, readable:
TypeError: processPayment is not a function
at handleCheckout (checkout.tsx:89:12)
at CheckoutButton.handleClick (CheckoutButton.tsx:45:8)
at onClick (form-events.ts:23:5)
Uploading Source Maps
Manual Upload via Dashboard:
- Go to Settings → Error Tracking → Source Maps
- Click Upload Source Map
- Fill in the details:
- Website: Select your website
- Release version: e.g.,
1.2.3 - Source map file: Select
dist/main.js.map - JavaScript URL:
https://example.com/assets/main.js
- Click Upload
Build Tool Integration
After your build generates source maps, upload them to Zenovay through the dashboard. For CI/CD pipelines, you can automate this by uploading source maps as part of your deployment process:
- Generate hidden source maps during build
- After deployment, upload the
.mapfiles via the dashboard at Settings → Error Tracking → Source Maps - Tag each upload with the release version for proper error correlation
Webpack - generate hidden source maps:
// webpack.config.js
module.exports = {
devtool: 'hidden-source-map',
// Source maps generated but not referenced in output
// Upload them to Zenovay via the API after build
};
Vite - generate hidden source maps:
// vite.config.js
export default {
build: {
sourcemap: 'hidden'
}
};
Rollup - generate hidden source maps:
// rollup.config.js
export default {
output: {
sourcemap: 'hidden'
}
};
Analyzing Common Patterns
Undefined Property Access
TypeError: Cannot read property 'name' of undefined
at renderUser (user-card.js:23:15)
Analysis:
- Object expected at line 23 is undefined
- Check data flow to
renderUser - Likely missing null check
Fix pattern:
// Before
const name = user.name;
// After
const name = user?.name ?? 'Unknown';
Function Not Defined
ReferenceError: processPayment is not defined
at handleSubmit (checkout.js:45:5)
Analysis:
- Function called but not in scope
- Check imports/exports
- Verify module loading order
Type Errors
TypeError: users.map is not a function
at renderUserList (list.js:12:20)
Analysis:
usersis not an array- Check API response format
- Verify data type assumptions
Advanced Analysis
Async Stack Traces
Modern JavaScript includes async context:
Error: API request failed
at fetchUser (api.js:34:11)
at async loadUserData (user-loader.js:56:18)
at async initApp (app.js:12:5)
Cross-Origin Frames
Third-party scripts show limited info:
Error: Script error.
at <anonymous> (https://third-party.com/widget.js:1:1)
Solution: Add CORS headers to third-party scripts:
<script src="https://third-party.com/widget.js" crossorigin="anonymous"></script>
Minified Third-Party Code
For libraries without source maps:
- Identify library from URL pattern
- Check library version
- Search for known issues
- Consider alternatives
Debugging Workflow
Step 1: Identify Error Location
- Look at top stack frame
- Note file, line, column
- Understand what code is doing
Step 2: Trace the Call Path
- Follow frames down the stack
- Identify data flow
- Find where bad data originates
Step 3: Check Context
- View error occurrence timeline
- Check affected browsers/devices
- Look for patterns (time, user type)
Step 4: Reproduce
- Use session replay (if available)
- Check user actions before error
- Test with same browser/conditions
Step 5: Fix and Verify
- Implement fix
- Deploy new version
- Mark error as resolved
- Monitor for regressions
IDE Integration
Open in VS Code
Configure external editor:
- Go to Settings → Integrations
- Select VS Code
- Enable "Open in Editor"
- Click stack frames to open
VS Code Extension
Install Zenovay extension:
- Install from VS Code marketplace
- Connect your account
- See errors inline in editor
- Click to view in dashboard
JetBrains IDEs
- Install Zenovay plugin
- Configure project mapping
- Navigate from errors to code
Release Correlation
Tag Releases
<script
data-tracking-code="YOUR_TRACKING_CODE"
src="https://api.zenovay.com/z.js"
></script>
Release Comparison
Compare errors between releases:
- Select two releases
- See new errors introduced
- See errors resolved
- Track regression rate
Suspect Commits
With Git integration:
- Error links to release
- Release links to commits
- Identify likely cause
Best Practices
Source Map Management
- Upload source maps during CI/CD
- Use hidden source maps in production
- Keep source maps organized by release
- Set retention policy
Stack Trace Quality
- Use meaningful function names
- Avoid anonymous functions
- Keep call stacks reasonable depth
- Add error context where needed
Debugging Efficiency
- Start with most impacted errors
- Use filters to focus analysis
- Document findings
- Share with team
Troubleshooting
Missing Source Maps
Check:
- Source maps uploaded for this release
- URL patterns match deployed files
- Release version matches
Incomplete Stack Traces
Causes:
- Async code not properly traced
- Errors from eval() or dynamic code
- Browser limitations
"Script error" Messages
Solutions:
- Add CORS headers
- Use crossorigin attribute
- Self-host third-party scripts