From c60385716b7a7ac9f788cdf7dfe37250321e0670 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 23 Aug 2023 14:05:05 -0700 Subject: Bunch of streams fixes (#4251) * Update WebKit * Don't do async hooks things when async hooks are not enabled * Smarter scheduling of event loop tasks with the http server * less exciting approach * Bump WebKit * Another approach * Fix body-stream tests * Fixes #1886 * Fix UAF in fetch body streaming * Missing from commit * Fix leak * Fix the other leak * Fix test * Fix crash * missing duperef * Make this code clearer * Ignore empty chunks * Fixes #3969 * Delete flaky test * Update bun-linux-build.yml * Fix memory issue * fix result body, and .done status before the last callback, dont touch headers after sent once * refactor HTTPClientResult * less flasky corrupted test * oops * fix mutex invalid state * fix onProgressUpdate deinit/unlock * fix onProgressUpdate deinit/unlock * oops * remove verbose * fix posible null use * avoid http null * metadata can still be used onReject after toResponse * dont leak task.http * fix flask tests * less flask close tests --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: cirospaciari --- src/js/node/async_hooks.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/js/node/async_hooks.ts') diff --git a/src/js/node/async_hooks.ts b/src/js/node/async_hooks.ts index 2a671b6a2..d04b226f8 100644 --- a/src/js/node/async_hooks.ts +++ b/src/js/node/async_hooks.ts @@ -21,7 +21,7 @@ // AsyncContextData is an immutable array managed in here, formatted [key, value, key, value] where // each key is an AsyncLocalStorage object and the value is the associated value. // -const { cleanupLater } = $lazy("async_hooks"); +const { cleanupLater, setAsyncHooksEnabled } = $lazy("async_hooks"); function get(): ReadonlyArray | undefined { return $getInternalField($asyncContext, 0); @@ -34,7 +34,9 @@ function set(contextValue: ReadonlyArray | undefined) { class AsyncLocalStorage { #disableCalled = false; - constructor() {} + constructor() { + setAsyncHooksEnabled(true); + } static bind(fn, ...args: any) { return this.snapshot().bind(null, fn, ...args); @@ -160,6 +162,7 @@ class AsyncResource { if (typeof type !== "string") { throw new TypeError('The "type" argument must be of type string. Received type ' + typeof type); } + setAsyncHooksEnabled(true); this.type = type; this.#snapshot = get(); } -- cgit v1.2.3