From c75c2e7a9fd559702c87787e0a1c6212522b9450 Mon Sep 17 00:00:00 2001 From: Matteo Manfredi Date: Tue, 27 Jun 2023 13:56:39 +0200 Subject: [PATCH 1/3] feat: replace `setTimeout()` with `queueMicrotask()` --- packages/astro/src/runtime/server/render/util.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/runtime/server/render/util.ts b/packages/astro/src/runtime/server/render/util.ts index 1f0aae047b34..182700976cbc 100644 --- a/packages/astro/src/runtime/server/render/util.ts +++ b/packages/astro/src/runtime/server/render/util.ts @@ -149,10 +149,10 @@ export function bufferIterators(iterators: AsyncIterable[]): AsyncIterable const eagerIterators = iterators.map((it) => new EagerAsyncIterableIterator(it)); // once the execution of the next for loop is suspended due to an async component, // this timeout triggers and we start buffering the other iterators - setTimeout(() => { + queueMicrotask(() => { // buffer all iterators that haven't started yet eagerIterators.forEach((it) => !it.isStarted() && it.buffer()); - }, 0); + }); return eagerIterators; } From b9b58f78e53255bfd6282eab73b17b64a356deeb Mon Sep 17 00:00:00 2001 From: Matteo Manfredi Date: Tue, 27 Jun 2023 14:27:22 +0200 Subject: [PATCH 2/3] Create sixty-tips-play.md --- .changeset/sixty-tips-play.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sixty-tips-play.md diff --git a/.changeset/sixty-tips-play.md b/.changeset/sixty-tips-play.md new file mode 100644 index 000000000000..8afe47da6c3b --- /dev/null +++ b/.changeset/sixty-tips-play.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Update `setTimeout()` to `queueMicrotask()` From 3b51a0df9d6d9375983459f59e7ff1bf107daa02 Mon Sep 17 00:00:00 2001 From: Matteo Manfredi Date: Tue, 27 Jun 2023 15:51:02 +0200 Subject: [PATCH 3/3] Update changeset --- .changeset/sixty-tips-play.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/sixty-tips-play.md b/.changeset/sixty-tips-play.md index 8afe47da6c3b..31ebef4dac2a 100644 --- a/.changeset/sixty-tips-play.md +++ b/.changeset/sixty-tips-play.md @@ -2,4 +2,4 @@ "astro": patch --- -Update `setTimeout()` to `queueMicrotask()` +Replaces the instance of `setTimeout()` in the runtime to use `queueMicrotask()`, to resolve limitations on Cloudflare Workers.