mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
18 lines
567 B
JavaScript
18 lines
567 B
JavaScript
const { AsyncLocalStorage } = require("async_hooks");
|
|
const crypto = require("crypto");
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
|
|
// Note: crypto.randomUUID is synchronous in Node.js
|
|
// Testing if async wrapper maintains context
|
|
asyncLocalStorage.run({ test: "crypto.randomUUID" }, () => {
|
|
setImmediate(() => {
|
|
const uuid = crypto.randomUUID();
|
|
if (asyncLocalStorage.getStore()?.test !== "crypto.randomUUID") {
|
|
console.error("FAIL: crypto.randomUUID async wrapper lost context");
|
|
process.exit(1);
|
|
}
|
|
process.exit(0);
|
|
});
|
|
});
|