Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[squash] document resource object and its limitations
  • Loading branch information
AndreasMadsen committed May 29, 2017
commit de40c745f9f2242a0d4dfc7260079891f71fcfe7
13 changes: 12 additions & 1 deletion doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,18 @@ hooks.
`triggerId` is the `id` of the resource that caused (or "triggered") the
new resource to initialize and that caused `init()` to call.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Either move this down to:

The following is a simple demonstration of triggerId:

Or make a note here that there's further explanation below.


The following is a simple demonstration of this:
`resource` is an object that represents the actual resource. This can contain
useful information such as the hostname for the `GETADDRINFOREQWRAP` resource
type, which will be used when looking up the ip for the hostname in
`net.Server.listen`. The API for getting this information is currently not
considered public, but using the Embedder API users can provide and document
their own resource objects. Such as resource object could for example contain
the SQL query being executed.

*Note:* In some cases the resource object is reused for performance reasons,
it is thus not safe to use it as a key in a `WeakMap` or add properties to it.

The following is a simple demonstration of `triggerId`:

```js
const async_hooks = require('async_hooks');
Expand Down