diff options
author | 2023-06-27 16:16:41 +0200 | |
---|---|---|
committer | 2023-06-27 22:16:41 +0800 | |
commit | 2726098bc82f910edda4198b9fb94f2bfd048976 (patch) | |
tree | 4b4b2463aa9c69d0b47b905935e88841388eb964 | |
parent | a82c6df25b1704670a4c98f05c11422ee878d3d1 (diff) | |
download | astro-2726098bc82f910edda4198b9fb94f2bfd048976.tar.gz astro-2726098bc82f910edda4198b9fb94f2bfd048976.tar.zst astro-2726098bc82f910edda4198b9fb94f2bfd048976.zip |
Update `setTimeout()` to `queueMicrotask()` (#7494)
-rw-r--r-- | .changeset/sixty-tips-play.md | 5 | ||||
-rw-r--r-- | packages/astro/src/runtime/server/render/util.ts | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/.changeset/sixty-tips-play.md b/.changeset/sixty-tips-play.md new file mode 100644 index 000000000..31ebef4da --- /dev/null +++ b/.changeset/sixty-tips-play.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Replaces the instance of `setTimeout()` in the runtime to use `queueMicrotask()`, to resolve limitations on Cloudflare Workers. diff --git a/packages/astro/src/runtime/server/render/util.ts b/packages/astro/src/runtime/server/render/util.ts index 1f0aae047..182700976 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<T>(iterators: AsyncIterable<T>[]): 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; } |