Skip to content

Commit 5cfe4e7

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[doc] Update checklist for new javascript features
The CL adds a dedicated section for "async stack traces" and "restart frame" with updated links. [email protected] Fixed: 374892098 Change-Id: I09c6a6edfeac11ef05a0aab775a2f0f03f1f58d6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5952204 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Simon Zünd <[email protected]>
1 parent ec822f3 commit 5cfe4e7

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

docs/checklist/javascript.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ as expression position for the exception. For syntax errors, we should report th
7676
Note that `Error.stack` is only collected for `Error` objects, at the time the `Error` object is constructed. This may be different
7777
than the stack trace passed to DevTools via [`JSMessageObject`](https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-objects.h;l=1264-1345;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa).
7878

79-
Independently from V8, DevTools offers a way to show async stack traces by stitching together stack traces collected at the
80-
location where the callback is passed, and the actual location of the exception inside the callback.
81-
8279
### Affected
8380

8481
NLFs that can cause an exception to be thrown, or can call into another function that throws.
@@ -95,12 +92,34 @@ Repeat with the "Disable async stack traces" checkbox in the Preferences checked
9592
Test cases for stack traces is mandatory, if there is any way the NLF can interact with throwing exceptions. For examples look
9693
for `mjsunit` tests with `stack-trace` in their names.
9794

98-
For async stack traces, please look at Blink LayoutTests such as [this one](https://chromium.googlesource.com/chromium/src/+/3daa588ce613845e298cbd667fa6f5787f95d574/third\_party/WebKit/LayoutTests/inspector/sources/debugger-async/async-await/async-callstack-async-await.html).
99-
10095
### Reading material
10196

10297
[Design doc for debugging support for tail-calls](https://docs.google.com/a/google.com/document/d/1Bk4QahtaT-XzrMlHTkm0SVol3LoKXTrC9E7INxJBHrE/edit?usp=drive\_web)
10398

99+
## Async stack traces
100+
101+
DevTools offers a way to show async stack traces by stitching together stack traces collected at the
102+
location where the callback is passed, and the actual location of the exception inside the callback.
103+
104+
The canonical example of this is throwing inside a `setTimeout` callback. The async stack trace will
105+
consist of the stack trace of the error plus a stack trace captured at the `setTimeout` call-site.
106+
107+
The instrumentation is based on four [`ayncTask*` methods](https://source.chromium.org/chromium/chromium/src/+/main:v8/include/v8-inspector.h;l=370-375;drc=aafd25ffbc72935b52fee731f957e5827c73a096). Namely `asyncTaskScheduled`, `asyncTaskStarted`, `asyncTaskFinished` and `asyncTaskCancelled`.
108+
V8 has a [higher-level interface](https://source.chromium.org/chromium/chromium/src/+/main:v8/src/debug/debug-interface.h;l=351-352;drc=e6fc2038d73ef96ff47deda3146d94d25530e13b) that translates Promise events (such as `await`, `.then`, etc) to these for `asyncTask*` methods.
109+
110+
### Affected
111+
112+
NLFs touching promises or callback scheduling.
113+
114+
### How to test
115+
116+
Throw or pause inside a new language feature and check either the call stack sidebar panel in "Sources"
117+
or use a `console.trace` and check the async stack trace in the console.
118+
119+
### Test cases
120+
121+
Test cases for async stack traces are mandatory, if there is any way the NLF interacts with callback scheduling or
122+
Promises. For examples look in V8 `inspector` tests with `async-stack` in their name (e.g. [here](https://source.chromium.org/chromium/chromium/src/+/main:v8/test/inspector/debugger/async-stack-await.js)).
104123

105124
## Catch prediction
106125

@@ -319,20 +338,38 @@ Take a heap Snapshot in DevTools' Profiler panel and inspect the result. Objects
319338

320339
Take a look at `test/cctest/test-heap-profiler.cc`.
321340

341+
## Restart frame
342+
343+
DevTools allows restarting of some stack frames, not just the top-level one. The feature is implemented by throwing a termination exception and unwinding the stack
344+
until after the function we want to restart, and then re-invoking the function. This only works for certain functions, e.g. async functions can't be restarted
345+
as that would require rolling back the underlying generator.
346+
347+
### Affected
348+
349+
NLFs that change function execution or require a function to carry state (e.g. async functions
350+
need a generator that can't be reset).
351+
352+
### How to test
353+
354+
While paused, right click a stack frame with the NLF in the call stack view and select "Restart frame". If the NLF prevents the frame from being restarted, then
355+
the "Restart frame" menu item must be disabled, otherwise the frame must be properly restarted.
356+
357+
### Test cases
358+
359+
Take a look in `test/inspector/debugger/restart-frame/*`.
322360

323361
## LiveEdit
324362

325363
LiveEdit is a feature that allows for script content to be replaced during its execution. While it has many limitations, the most often use case
326-
of editing the function we are paused in and restarting said function usually works.
364+
of editing the function we are paused in and restarting said function afterwards.
327365

328366
### Affected
329367

330368
NLFs that affect code execution
331369

332370
### How to test
333371

334-
Open DevTools and break inside the part of script affected by the NLF. In the Source panel's Call Stack view, right-click the top-most frame and select
335-
Restart Frame.
372+
Open DevTools and break inside the part of script affected by the NLF. Change the code inside the function with the NLF and save the script.
336373

337374
### Test cases
338375

0 commit comments

Comments
 (0)