Skip to content
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
guybedford and aduh95 authored Jun 15, 2021
commit 60a75e924fae4f506aeb1e3dc906bd03e8457b40
6 changes: 4 additions & 2 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ this.
```mjs
import { createServer } from 'net';

net.createServer().listen(function() { this.close(); });
createServer().listen(function() { this.close(); });
// OR
clearTimeout(setTimeout(() => {}, 10));
```
Expand Down Expand Up @@ -358,6 +358,7 @@ The following is a simple demonstration of `triggerAsyncId`:
```mjs
import { createHook, executionASyncId } from 'async_hooks';
import { stdout } from 'process';
Comment thread
guybedford marked this conversation as resolved.
import net from 'net';

createHook({
init(asyncId, type, triggerAsyncId) {
Expand All @@ -374,6 +375,7 @@ net.createServer((conn) => {}).listen(8080);
```cjs
const { createHook, executionAsyncId } = require('async_hooks');
const { fd } = require('process').stdout;
Comment thread
guybedford marked this conversation as resolved.
const net = require('net');

createHook({
init(asyncId, type, triggerAsyncId) {
Expand Down Expand Up @@ -613,7 +615,7 @@ import { open } from 'fs';
import { executionAsyncId, executionAsyncResource } from 'async_hooks';

console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
open(fileURLToPath(import.meta.url), 'r', (err, fd) => {
open(new URL(import.meta.url), 'r', (err, fd) => {
console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
});
```
Expand Down