@@ -460,7 +460,7 @@ init for PROMISE with id 6, trigger id: 5 # the Promise returned by then()
460460 after 6
461461```
462462
463- #### async_hooks.currentResource ()
463+ #### async_hooks.executionAsyncResource ()
464464
465465<!-- YAML
466466added: REPLACEME
@@ -472,11 +472,11 @@ added: REPLACEME
472472
473473``` js
474474const { open } = require (' fs' );
475- const { executionAsyncId , currentResource } = require (' async_hooks' );
475+ const { executionAsyncId , executionAsyncResource } = require (' async_hooks' );
476476
477- console .log (executionAsyncId (), currentResource ()); // 1 null
477+ console .log (executionAsyncId (), executionAsyncResource ()); // 1 null
478478open (__filename , ' r' , (err , fd ) => {
479- console .log (executionAsyncId (), currentResource ()); // 7 FSReqWrap
479+ console .log (executionAsyncId (), executionAsyncResource ()); // 7 FSReqWrap
480480});
481481```
482482
@@ -487,29 +487,29 @@ using of a tracking `Map` to store the metadata:
487487const { createServer } = require (' http' );
488488const {
489489 executionAsyncId ,
490- currentResource ,
490+ executionAsyncResource ,
491491 createHook
492492} = require (' async_hooks' );
493493const sym = Symbol (' state' ); // Private symbol to avoid pollution
494494
495495createHook ({
496496 init (asyncId , type , triggerAsyncId , resource ) {
497- const cr = currentResource ();
497+ const cr = executionAsyncResource ();
498498 if (cr) {
499499 resource[sym] = cr[sym];
500500 }
501501 }
502502}).enable ();
503503
504504const server = createServer (function (req , res ) {
505- currentResource ()[sym] = { state: req .url };
505+ executionAsyncResource ()[sym] = { state: req .url };
506506 setTimeout (function () {
507- res .end (JSON .stringify (currentResource ()[sym]));
507+ res .end (JSON .stringify (executionAsyncResource ()[sym]));
508508 }, 100 );
509509}).listen (3000 );
510510```
511511
512- ` currentResource ()` will return ` null ` during application bootstrap.
512+ ` executionAsyncResource ()` will return ` null ` during application bootstrap.
513513
514514#### async_hooks.executionAsyncId()
515515
0 commit comments