mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
26 lines
639 B
JavaScript
26 lines
639 B
JavaScript
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();
|
|
});
|