From ab5e67edb63f10521ea7a45176bba4bb58aef76b Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 29 Oct 2024 15:01:02 +0900 Subject: [PATCH 1/5] test(async): fix flakiness of throttle example --- async/unstable_throttle.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/async/unstable_throttle.ts b/async/unstable_throttle.ts index cc48ef2299bd..1fe448744f59 100644 --- a/async/unstable_throttle.ts +++ b/async/unstable_throttle.ts @@ -41,7 +41,11 @@ export interface ThrottledFunction> { * import { assert } from "@std/assert" * * let called = 0; - * await using server = Deno.serve({ port: 0, onListen:() => null }, () => new Response(`${called++}`)); + * const requestReceived = Promise.withResolvers(); + * await using server = Deno.serve({ port: 0 }, () => { + * requestReceived.resolve(); + * return new Response(`${called++}`) + * }); * * // A throttled function will be executed at most once during a specified ms timeframe * const timeframe = 100 @@ -51,6 +55,7 @@ export interface ThrottledFunction> { * } * * await retry(() => assert(!func.throttling)) + * await requestReceived.promise; * assert(called === 1) * assert(!Number.isNaN(func.lastExecution)) * ``` From 649ef6d5643f100c6ec3debe9b5e73ec603e654f Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 29 Oct 2024 16:16:46 +0900 Subject: [PATCH 2/5] rerun From 61ad60b94cf821030ca31c9b324fbbd774dc99fc Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 29 Oct 2024 16:16:49 +0900 Subject: [PATCH 3/5] rerun From 8212667b12a9e032f9e92c68f55385e06c984859 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 29 Oct 2024 16:16:52 +0900 Subject: [PATCH 4/5] rerun From 4939ca728f642390d41e5804c2efb9747ba72405 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 29 Oct 2024 16:16:55 +0900 Subject: [PATCH 5/5] rerun