pi-awaken 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +11 -2
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -93,9 +93,18 @@ export default function (pi: ExtensionAPI) {
|
|
|
93
93
|
if (queued.has(wake.key)) return;
|
|
94
94
|
queued.add(wake.key);
|
|
95
95
|
queue.push(wake);
|
|
96
|
-
flushTimer ??= setTimeout(flush, FLUSH_MS);
|
|
96
|
+
flushTimer ??= setTimeout(() => guarded(flush), FLUSH_MS);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
+
function guarded(fn: () => void) {
|
|
100
|
+
try {
|
|
101
|
+
fn();
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error instanceof Error && error.message.includes("ctx is stale")) shutdown();
|
|
104
|
+
else throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
99
108
|
function flush() {
|
|
100
109
|
flushTimer = undefined;
|
|
101
110
|
const s = store;
|
|
@@ -188,7 +197,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
188
197
|
store.ensure();
|
|
189
198
|
JobStore.prune();
|
|
190
199
|
installCli();
|
|
191
|
-
pollTimer = setInterval(tick, POLL_MS);
|
|
200
|
+
pollTimer = setInterval(() => guarded(tick), POLL_MS);
|
|
192
201
|
pollTimer.unref?.();
|
|
193
202
|
tick();
|
|
194
203
|
});
|
package/package.json
CHANGED