aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/async_hooks.exports.js20
-rw-r--r--src/js_printer.zig4
2 files changed, 9 insertions, 15 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;
diff --git a/src/js_printer.zig b/src/js_printer.zig
index 5b4d3c26c..4aa3b1c7c 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -1369,7 +1369,7 @@ pub fn NewPrinter(
if (i < n) {
const c2: CodeUnitType = text[i];
- if (c2 >= first_high_surrogate and c2 <= last_low_surrogate) {
+ if (c2 >= first_low_surrogate and c2 <= last_low_surrogate) {
i += 1;
// Escape this character if UTF-8 isn't allowed
@@ -1420,7 +1420,7 @@ pub fn NewPrinter(
}
} else {
// chars < 255 as two digit hex escape
- if (c < 0xFF) {
+ if (c <= 0xFF) {
var ptr = e.writer.reserve(4) catch unreachable;
ptr[0..4].* = [_]u8{ '\\', 'x', hex_chars[c >> 4], hex_chars[c & 15] };
e.writer.advance(4);