@astrosheep/square 0.3.25 → 0.3.26
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/extensions/square-pi.js
CHANGED
|
@@ -44,6 +44,14 @@ export default function squarePiExtension(pi) {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
// A transport may keep its promise pending while Pi is shutting down or
|
|
48
|
+
// replacing a session. Never make a lifecycle hook wait for that transport.
|
|
49
|
+
const stopWatcher = () => {
|
|
50
|
+
watcherAbort?.abort();
|
|
51
|
+
watcher = undefined;
|
|
52
|
+
watcherAbort = undefined;
|
|
53
|
+
};
|
|
54
|
+
|
|
47
55
|
const wake = async (piContext, token, signal) => {
|
|
48
56
|
while (sessionId !== undefined && token === generation && !signal.aborted) {
|
|
49
57
|
const deferredRetry = retryAfterChange;
|
|
@@ -91,10 +99,7 @@ export default function squarePiExtension(pi) {
|
|
|
91
99
|
|
|
92
100
|
pi.on('session_start', async (_event, ctx) => {
|
|
93
101
|
generation += 1;
|
|
94
|
-
|
|
95
|
-
if (watcher) await watcher;
|
|
96
|
-
watcher = undefined;
|
|
97
|
-
watcherAbort = undefined;
|
|
102
|
+
stopWatcher();
|
|
98
103
|
handledPending.clear();
|
|
99
104
|
retryAfterChange = false;
|
|
100
105
|
sessionId = ctx.sessionManager.getSessionId();
|
|
@@ -130,10 +135,7 @@ export default function squarePiExtension(pi) {
|
|
|
130
135
|
|
|
131
136
|
pi.on('session_shutdown', async () => {
|
|
132
137
|
generation += 1;
|
|
133
|
-
|
|
134
|
-
if (watcher) await watcher;
|
|
135
|
-
watcher = undefined;
|
|
136
|
-
watcherAbort = undefined;
|
|
138
|
+
stopWatcher();
|
|
137
139
|
for (const waiter of settledWaiters) waiter.resolve();
|
|
138
140
|
settledWaiters = [];
|
|
139
141
|
if (sessionId && sessionCwd) await automaticSessionEnd('pi', sessionId, sessionCwd);
|