aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/async_hooks.exports.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/async_hooks.exports.js')
-rw-r--r--src/bun.js/async_hooks.exports.js20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/bun.js/async_hooks.exports.js b/src/bun.js/async_hooks.exports.js
index 9dfff7ef1..c5bc6f620 100644
--- a/src/bun.js/async_hooks.exports.js
+++ b/src/bun.js/async_hooks.exports.js
@@ -3,18 +3,11 @@ var drainMicrotasks = () => {
drainMicrotasks();
};
-const warnOnce = fn => {
- let warned = false;
- return (...args) => {
- if (!warned) {
- warned = true;
- fn(...args);
- }
- };
+var notImplemented = () => {
+ console.warn("[bun]: async_hooks has not been implemented yet :(");
+ notImplemented = () => {};
};
-const notImplemented = warnOnce(() => console.warn("[bun]: async_hooks has not been implemented yet :("));
-
class AsyncLocalStorage {
#store;
_enabled;
@@ -39,9 +32,9 @@ class AsyncLocalStorage {
run(store, callback, ...args) {
if (typeof callback !== "function") throw new TypeError("ERR_INVALID_CALLBACK");
- const prev = this.#store;
+ var prev = this.#store;
var result, err;
- process.nextTick(() => {
+ process.nextTick(store => {
this.enterWith(store);
try {
result = callback(...args);
@@ -49,8 +42,9 @@ class AsyncLocalStorage {
err = e;
} finally {
this.#store = prev;
+ prev = undefined;
}
- });
+ }, store);
drainMicrotasks();
if (typeof err !== "undefined") {
throw err;