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>
35 lines
929 B
JavaScript
35 lines
929 B
JavaScript
const { AsyncLocalStorage } = require("async_hooks");
|
|
const zlib = require("zlib");
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
let failed = false;
|
|
|
|
asyncLocalStorage.run({ test: "zlib.createGzip" }, () => {
|
|
const gzip = zlib.createGzip();
|
|
|
|
gzip.on("data", chunk => {
|
|
if (asyncLocalStorage.getStore()?.test !== "zlib.createGzip") {
|
|
console.error("FAIL: zlib.createGzip data event lost context");
|
|
failed = true;
|
|
}
|
|
});
|
|
|
|
gzip.on("end", () => {
|
|
if (asyncLocalStorage.getStore()?.test !== "zlib.createGzip") {
|
|
console.error("FAIL: zlib.createGzip end event lost context");
|
|
failed = true;
|
|
}
|
|
process.exit(failed ? 1 : 0);
|
|
});
|
|
|
|
gzip.on("finish", () => {
|
|
if (asyncLocalStorage.getStore()?.test !== "zlib.createGzip") {
|
|
console.error("FAIL: zlib.createGzip finish event lost context");
|
|
failed = true;
|
|
}
|
|
});
|
|
|
|
gzip.write("test data");
|
|
gzip.end();
|
|
});
|