Files
bun.sh/test/js/node/async_hooks/async-context/async-context-https-request.js
Jarred Sumner e1505b7143 Use JSC::Integrity:: auditCellFully in bindings (#22538)
### What does this PR do?

### How did you verify your code works?
2025-09-10 00:31:54 -07:00

27 lines
661 B
JavaScript

process.exitCode = 1;
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();
});