mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Update setTimeout()
to queueMicrotask()
(#7494)
This commit is contained in:
parent
a82c6df25b
commit
2726098bc8
2 changed files with 7 additions and 2 deletions
5
.changeset/sixty-tips-play.md
Normal file
5
.changeset/sixty-tips-play.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Replaces the instance of `setTimeout()` in the runtime to use `queueMicrotask()`, to resolve limitations on Cloudflare Workers.
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue