File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -483,8 +483,47 @@ This is what the proposal evolved from. `async_hooks` in Node.js enabled async
483
483
resources tracking for APM vendors. On which Node.js also implemented
484
484
` AsyncLocalStorage ` .
485
485
486
+ ## Chrome Async Stack Tagging API
487
+
488
+ Frameworks can schedule tasks with their own userland queues. In such case, the
489
+ stack trace originated from the framework scheduling logic tells only part of
490
+ the story.
491
+
492
+ ``` console
493
+ Error: Call stack
494
+ at someTask (example.js)
495
+ at loop (framework.js)
496
+ ```
497
+
498
+ The Chrome [ Async Stack Tagging API] [ ] introduces a new console method named
499
+ ` console.createTask() ` . The API signature is as follows:
500
+
501
+ ``` typescript
502
+ interface Console {
503
+ createTask(name : string ): Task ;
504
+ }
505
+
506
+ interface Task {
507
+ run<T >(f : () => T ): T ;
508
+ }
509
+ ```
510
+
511
+ ` console.createTask() ` snapshots the call stack into a ` Task ` record. And each
512
+ ` Task.run() ` restores the saved call stack and append it to newly generated
513
+ call stacks.
514
+
515
+ ``` console
516
+ Error: Call stack
517
+ at someTask (example.js)
518
+ at loop (framework.js) // <- Task.run
519
+ at async someTask // <- Async stack appended
520
+ at schedule (framework.js) // <- console.createTask
521
+ at businessLogic (example.js)
522
+ ```
523
+
486
524
[ async stack traces ] : https://v8.dev/docs/stack-trace-api#async-stack-traces
487
525
[ `AsyncResource.runInAsyncScope` ] : https://nodejs.org/dist/latest-v14.x/docs/api/async_hooks.html#async_hooks_asyncresource_runinasyncscope_fn_thisarg_args
488
526
[ Domain Module Postmortem ] : https://nodejs.org/en/docs/guides/domain-postmortem/
489
527
[ SOLUTION.md ] : ./SOLUTION.md
490
528
[ SCOPING.md ] : ./SCOPING.md
529
+ [ Async Stack Tagging API ] : https://developer.chrome.com/blog/devtools-modern-web-debugging/#linked-stack-traces
You can’t perform that action at this time.
0 commit comments