diff options
author | 2023-02-15 00:36:01 -0800 | |
---|---|---|
committer | 2023-02-15 00:36:18 -0800 | |
commit | c83eaf09b9fa27c961c845c5eddc075384b244fc (patch) | |
tree | 2728fff3aaeeed4291bae6450ebf410ac99338c3 /src/bun.js/async_hooks.exports.js | |
parent | 4320108add7aa43e6e9ff88fff45b620d1292354 (diff) | |
download | bun-c83eaf09b9fa27c961c845c5eddc075384b244fc.tar.gz bun-c83eaf09b9fa27c961c845c5eddc075384b244fc.tar.zst bun-c83eaf09b9fa27c961c845c5eddc075384b244fc.zip |
some cleanup
Diffstat (limited to 'src/bun.js/async_hooks.exports.js')
-rw-r--r-- | src/bun.js/async_hooks.exports.js | 20 |
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; |