mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
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:
@@ -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();
|
||||
});
|
||||
Reference in New Issue
Block a user