Agent SkillsChromeDevTools/devtools-frontend › devtools-source-maps

devtools-source-maps

GitHub

指导在 DevTools 前端正确使用 Source Maps 和结构化堆栈追踪,涵盖 API 调用、模型处理及 UI 组件渲染,避免内存泄漏。

.agents/skills/devtools-source-maps/SKILL.md ChromeDevTools/devtools-frontend

Trigger Scenarios

需要解析或展示源代码映射后的堆栈信息 实现错误信息的符号化与可视化展示

Install

npx skills add ChromeDevTools/devtools-frontend --skill devtools-source-maps -g -y
More Options

Non-standard path

npx skills add https://github.com/ChromeDevTools/devtools-frontend/tree/main/.agents/skills/devtools-source-maps -g -y

Use without installing

npx skills use ChromeDevTools/devtools-frontend@devtools-source-maps

指定 Agent (Claude Code)

npx skills add ChromeDevTools/devtools-frontend --skill devtools-source-maps -a claude-code -g -y

安装 repo 全部 skill

npx skills add ChromeDevTools/devtools-frontend --all -g -y

预览 repo 内 skill

npx skills add ChromeDevTools/devtools-frontend --list

SKILL.md

Frontmatter
{
    "name": "devtools-source-maps",
    "description": "Guidelines for utilizing source maps and structured stack traces in DevTools. Covers DebuggerWorkspaceBinding, StackTrace, SymbolizedError, and related UI widgets."
}

Utilizing Source Maps & Structured Stack Traces in DevTools

This skill guides you on how to correctly map runtime coordinates to original source locations and render structured stack traces or symbolized errors in the DevTools frontend.


1. Primary Rules

  1. Never parse raw error stacks manually: Do not split on newlines or use homebrew regex to parse stack traces. Use DebuggerWorkspaceBinding helpers to structurally parse and translate stack traces.
  2. Dispose of subscriptions: Models like SymbolizedError subscribe to live locations. Always call .dispose() when the consumer (e.g., a widget or list) is destroyed to avoid memory leaks.
  3. Prefer pre-built widgets: Instead of manually formatting or rendering call frames, use StackTracePreviewContent for raw stacks, and SymbolizedErrorWidget for complete errors.

2. Core Abstractions

A. StackTrace Model (front_end/models/stack_trace/)

A structured representation of a call stack (synchronous + asynchronous segments).

  • StackTrace / ParsedErrorStackTrace / DebuggableStackTrace: Dispatches a StackTrace.Events.UPDATED event when the original sources are fully resolved or update.
  • Frame: Represents a single frame, which contains uiSourceCode, url, line/column info, untranslated rawName, translated name, and inline information.

B. SymbolizedError Model (front_end/models/bindings/SymbolizedError.ts)

A union type representing a fully symbolized error.

  • SymbolizedErrorObject: Contains error message, stackTrace (as a ParsedErrorStackTrace), and an optional cause (another SymbolizedError). Also holds compile/eval syntaxErrorLocation.
  • UnparsableError: Fallback when parsing fails.

3. Core APIs on DebuggerWorkspaceBinding

Location Translation

Translates raw coordinates into UI-friendly original source coordinates:

const uiLocation = await Bindings.DebuggerWorkspaceBinding.instance()
    .rawLocationToUILocation(rawLocation);

StackTrace & Error Generation

  • From Protocol Stack Trace (Runtime Domain):
    const stack = await Bindings.DebuggerWorkspaceBinding.instance()
        .createStackTraceFromProtocolRuntime(protocolStackTrace, target);
    
  • From Debugger Pause details:
    const stack = await Bindings.DebuggerWorkspaceBinding.instance()
        .createStackTraceFromDebuggerPaused(pausedDetails, target);
    
  • From a Raw Error Stack string:
    const stack = await Bindings.DebuggerWorkspaceBinding.instance()
        .createStackTraceFromErrorStackLikeString(target, stackString, exceptionDetails);
    
  • From a Remote Error Object:
    const symbolizedError = await Bindings.DebuggerWorkspaceBinding.instance()
        .createSymbolizedError(remoteObject, exceptionDetails);
    

4. UI Widget Reference

StackTracePreviewContent

Renders a structured StackTrace inside Shadow DOM. Handles expandable UI and collapsing ignore-listed files.

import * as Components from '../../ui/legacy/components/utils/utils.js';
import * as Workspace from '../../models/workspace/workspace.js';

const preview = new Components.JSPresentationUtils.StackTracePreviewContent();
preview.stackTrace = stackTrace;
preview.options = {
  expandable: true,
  showColumnNumber: true,
  ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager.instance(),
};
this.contentElement.appendChild(preview.element);

SymbolizedErrorWidget

Displays a complete SymbolizedError including recursive causal chains ("Caused by: ...") and syntax error locations.

import * as Panels from '../../panels/panels.js';
import * as Workspace from '../../models/workspace/workspace.js';

const errorWidget = new Panels.Console.SymbolizedErrorWidget();
errorWidget.error = symbolizedError;
errorWidget.ignoreListManager = Workspace.IgnoreListManager.IgnoreListManager
    .instance();
this.contentElement.appendChild(errorWidget.element);

5. Verification Checklist

  1. Check for Memory Leaks: Verify symbolizedError.dispose() is called on consumer widget cleanup.
  2. Ignore-listing Support: Ensure widgets have ignoreListManager set.
  3. WASM/Inline Support: Check that inline and WebAssembly frames map correctly via original source maps.

Version History

  • 678d19c Current 2026-08-20 15:20

Same Skill Collection

.agents/skills/devtools-ci/SKILL.md
.agents/skills/devtools-imports/SKILL.md
.agents/skills/devtools-model-management/SKILL.md
.agents/skills/devtools-setting-migration/SKILL.md
.agents/skills/devtools-testing-guidance/SKILL.md
.agents/skills/devtools-unicode-escaping/SKILL.md
.agents/skills/devtools-ux-writing-refactor/SKILL.md
.agents/skills/devtools-verification/SKILL.md
.agents/skills/evaluate-ai-css-completion/SKILL.md
.agents/skills/fixing-skipped-tests/SKILL.md
.agents/skills/foundation-test-migration/SKILL.md
.agents/skills/gerrit-cli/SKILL.md
.agents/skills/merging-devtools-module/SKILL.md
.agents/skills/migrate-chromium-test/SKILL.md
.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md
.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md
.agents/skills/ui-eng-vision-orchestrator/SKILL.md
.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md
.agents/skills/ui-eng-vision-widget-promoter/SKILL.md
.agents/skills/ui-widgets/SKILL.md
.agents/skills/version-control/SKILL.md
.agents/skills/repro-flaky-tests/SKILL.md

Metadata

Files
0
Version
678d19c
Hash
9efd75a2
Indexed
2026-08-20 15:20

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 17:06
浙ICP备14020137号-1 $방문자$