We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 70e19d5 commit cd95a95Copy full SHA for cd95a95
src/pages/chat/pending-callbacks.ts
@@ -11,7 +11,14 @@ declare const window: WindowWithPendingCallbacks;
11
12
window.__usePendingCallbacks = window.__usePendingCallbacks ?? false;
13
window.__pendingCallbacks = [];
14
-window.__flushOne = () => window.__pendingCallbacks.shift()?.();
+window.__flushOne = () => {
15
+ const nextCallback = window.__pendingCallbacks.shift();
16
+ if (nextCallback) {
17
+ nextCallback();
18
+ } else {
19
+ throw new Error('The callbacks queue is empty.');
20
+ }
21
+};
22
window.__flushAll = () => {
23
while (window.__pendingCallbacks.length) {
24
window.__flushOne();
0 commit comments