Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Inconsistent AsyncLocalStorage behavior between Node.js 20 and 24 when combining exit() and enterWith() | GoodFirstPicks

Inconsistent AsyncLocalStorage behavior between Node.js 20 and 24 when combining exit() and enterWith()

nodejs/node 1 comments 14d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeTest focusedNode.jsJavaScript

Why this is a good first issue

Behavioral inconsistency in AsyncLocalStorage between Node.js versions requires investigation.

AI Summary

The issue reports inconsistent behavior in AsyncLocalStorage between Node.js 20 and 24 when combining exit() and enterWith() methods. The expected behavior in Node.js 20 differs from Node.js 24, causing issues during major version upgrades. The problem requires investigation into the AsyncLocalStorage implementation changes between versions.

Issue Description

Version

24.14.0

Platform

I've encountered an inconsistency in AsyncLocalStorage behavior between Node.js 20 and 24 when using a combination of exit() and enterWith() methods. This change caused our major version upgrade to be blocked.

Subsystem

No response

What steps will reproduce the bug?

const { AsyncLocalStorage } = require("async_hooks");
const http = require("http");
const storage = new AsyncLocalStorage();
// Set global store
storage.enterWith({ test1: 'test1' });
const server = http.createServer(async (req, res) => {
    storage.exit(() => {
        console.log('store 0----', storage.getStore());  // undefined (expected)
        
        storage.enterWith({ test2: 'test2' });
        
        const _handler = () => {
            console.log('store 2----', storage.getStore());
        };
        
        console.log('store 1----', storage.getStore());  // { test5: 'test2' } (expected)
        res.on("finish", () => _handler());
    });
    
    res.end('Hello World from port 8083\n');
});

server.listen(8084, () => {
    console.log('Example: curl http://localhost:8084');
});

Node.js 20 output: Example: curl http://localhost:8084 store 0---- undefined store 1---- { test2: 'test2' } store 2---- { test2: 'test2' }

Node.js 24 output: Example: curl http://localhost:8084 store 0---- undefined store 1---- { test2: 'test2' } store 2---- { test1: 'test1' }

How often does it reproduce? Is there a required condition?

no

What is the expected behavior? Why is that the expected behavior?

no

What do you see instead?

no

Additional information

no

GitHub Labels

async_local_storage

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • behavioral inconsistency
  • version-specific issue
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes