Fix several missing async context tracking callbacks (#20759)

Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
This commit is contained in:
Jarred Sumner
2025-07-02 17:45:00 -07:00
committed by GitHub
parent a04cf04cd5
commit 5a7b5ceb33
96 changed files with 1997 additions and 136 deletions

View File

@@ -0,0 +1,25 @@
const { AsyncLocalStorage } = require("async_hooks");
const https = require("https");
const asyncLocalStorage = new AsyncLocalStorage();
asyncLocalStorage.run({ test: "https.request" }, () => {
const req = https.request("https://httpbin.org/get", res => {
if (asyncLocalStorage.getStore()?.test !== "https.request") {
console.error("FAIL: https.request response callback lost context");
process.exit(1);
}
res.on("data", () => {});
res.on("end", () => {
process.exit(0);
});
});
req.on("error", () => {
// Skip test if network is unavailable
process.exit(0);
});
req.end();
});