From cbb274b52f226dee3c0128cade12821e86a63c85 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sun, 7 Nov 2021 13:39:12 +0530 Subject: [PATCH] async_hooks: return topmost owner from executionAsyncResource() Signed-off-by: Darshan Sen --- lib/internal/async_hooks.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 390453ca7b8aa9..d1514591c65fc7 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -179,11 +179,8 @@ function fatalError(e) { function lookupPublicResource(resource) { if (typeof resource !== 'object' || resource === null) return resource; - const publicResource = resource[owner_symbol]; - - if (publicResource != null) { - return publicResource; - } + let owner; + while ((owner = resource[owner_symbol]) != null) resource = owner; return resource; }