Skip to content

perf: introduce cached trace map for stack parsing#6839

Merged
chenjiahan merged 1 commit intomainfrom
cached_trace_map_1225
Dec 26, 2025
Merged

perf: introduce cached trace map for stack parsing#6839
chenjiahan merged 1 commit intomainfrom
cached_trace_map_1225

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Create and pass a cachedTraceMap map when formatting browser error logs and full stack traces, further reducing redundant file reads and new TraceMap() during error handling.

Before

Screenshot 2025-12-25 at 22 03 48

After

Screenshot 2025-12-25 at 22 04 50

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings December 25, 2025 14:07
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 25, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 1fb9419
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/694d453afb547a000865d939
😎 Deploy Preview https://deploy-preview-6839--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 71 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a performance optimization for browser error log formatting by implementing a caching mechanism for TraceMap objects. The cache reduces redundant file reads and TraceMap instantiations when parsing stack traces from browser errors.

  • Introduced a CachedTraceMap type (Map<string, TraceMap>) to cache TraceMap instances by source map file path
  • Refactored parseFrame function to use the cache and avoid re-reading/re-parsing the same source maps
  • Updated function signatures throughout the call chain to thread the cache through

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/core/src/server/browserLogs.ts Added CachedTraceMap type, refactored parseFrame to implement caching logic, and updated all related function signatures to accept and pass through the cache
packages/core/src/server/socketServer.ts Creates a new cache instance per error handling session and passes it to formatBrowserErrorLog calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan merged commit 6293c73 into main Dec 26, 2025
18 checks passed
@chenjiahan chenjiahan deleted the cached_trace_map_1225 branch December 26, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants