@meetquinn/animactl 0.1.13-canary.424.1.efdd965 → 0.1.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resilient-socket-mode-receiver.d.ts","sourceRoot":"","sources":["../../../server/slack/resilient-socket-mode-receiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EAAgC,KAAK,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAOhG,UAAU,kCAAmC,SAAQ,yBAAyB;IAC5E,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;CACzD;
|
|
1
|
+
{"version":3,"file":"resilient-socket-mode-receiver.d.ts","sourceRoot":"","sources":["../../../server/slack/resilient-socket-mode-receiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EAAgC,KAAK,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAOhG,UAAU,kCAAmC,SAAQ,yBAAyB;IAC5E,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;CACzD;AAQD,qBAAa,2BAA4B,SAAQ,kBAAkB;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,OAAO,CAAC,aAAa,CAAC,CAAgB;IACtC,OAAO,CAAC,UAAU,CAAC,CAA6C;IAChE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,kCAAkC;IAgBxC,KAAK,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAQ7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpC,OAAO,CAAC,cAAc;YASR,mBAAmB;YAQnB,wBAAwB;YAWxB,mBAAmB;IAiCjC,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,iBAAiB;YAQX,gBAAgB;CAK/B"}
|
|
@@ -26,11 +26,11 @@ export class ResilientSocketModeReceiver extends SocketModeReceiver {
|
|
|
26
26
|
}
|
|
27
27
|
async start() {
|
|
28
28
|
this.stopping = false;
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
29
|
+
const outcome = await this.connectUntilStopped();
|
|
30
|
+
if (outcome.kind === 'stopped')
|
|
31
31
|
throw new Error('Slack Socket Mode startup stopped before connecting');
|
|
32
32
|
this.started = true;
|
|
33
|
-
return
|
|
33
|
+
return outcome.response;
|
|
34
34
|
}
|
|
35
35
|
async stop() {
|
|
36
36
|
this.started = false;
|
|
@@ -59,8 +59,8 @@ export class ResilientSocketModeReceiver extends SocketModeReceiver {
|
|
|
59
59
|
}
|
|
60
60
|
async reconnectAfterDisconnect() {
|
|
61
61
|
try {
|
|
62
|
-
const
|
|
63
|
-
if (connected && !this.stopping) {
|
|
62
|
+
const outcome = await this.connectUntilStopped();
|
|
63
|
+
if (outcome.kind === 'connected' && !this.stopping) {
|
|
64
64
|
this.runtimeLogger.log('Slack Socket Mode reconnected.');
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -76,13 +76,13 @@ export class ResilientSocketModeReceiver extends SocketModeReceiver {
|
|
|
76
76
|
// The SDK resolves undefined after a real successful hello despite its
|
|
77
77
|
// declared AppsConnectionsOpenResponse return type.
|
|
78
78
|
if (!this.stopping)
|
|
79
|
-
return { response };
|
|
79
|
+
return { kind: 'connected', response };
|
|
80
80
|
await this.disconnectClient();
|
|
81
|
-
return
|
|
81
|
+
return { kind: 'stopped' };
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
84
84
|
if (this.stopping)
|
|
85
|
-
return
|
|
85
|
+
return { kind: 'stopped' };
|
|
86
86
|
if (fatalSocketStartError(error)) {
|
|
87
87
|
this.runtimeLogger.error(`Slack Socket Mode connection failed permanently: ${errorMessage(error)}`);
|
|
88
88
|
throw error;
|
|
@@ -92,10 +92,10 @@ export class ResilientSocketModeReceiver extends SocketModeReceiver {
|
|
|
92
92
|
this.runtimeLogger.warn(`Slack Socket Mode connection failed; retrying in ${delayMs}ms: ${errorMessage(error)}`);
|
|
93
93
|
await this.waitForRetry(delayMs);
|
|
94
94
|
if (this.stopping)
|
|
95
|
-
return
|
|
95
|
+
return { kind: 'stopped' };
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
return
|
|
98
|
+
return { kind: 'stopped' };
|
|
99
99
|
}
|
|
100
100
|
waitForRetry(delayMs) {
|
|
101
101
|
return new Promise((resolve) => {
|
|
@@ -33,8 +33,11 @@ async function probe(make) {
|
|
|
33
33
|
let attempts = 0;
|
|
34
34
|
receiver.client.start = async () => {
|
|
35
35
|
attempts += 1;
|
|
36
|
+
// The real SDK fulfills `undefined` after a successful hello, despite its
|
|
37
|
+
// declared AppsConnectionsOpenResponse return type. Stub the world, not our
|
|
38
|
+
// idea of it: a `{ ok: true }` stub is what let the .423 outage ship green.
|
|
36
39
|
if (attempts === 1)
|
|
37
|
-
return
|
|
40
|
+
return undefined;
|
|
38
41
|
throw make();
|
|
39
42
|
};
|
|
40
43
|
await receiver.start();
|
|
@@ -93,9 +96,12 @@ test('stop() during an in-flight connect leaves no live socket', async () => {
|
|
|
93
96
|
let release;
|
|
94
97
|
receiver.client.start = async () => {
|
|
95
98
|
attempts += 1;
|
|
99
|
+
// The real SDK fulfills `undefined` after a successful hello, despite its
|
|
100
|
+
// declared AppsConnectionsOpenResponse return type. Stub the world, not our
|
|
101
|
+
// idea of it: a `{ ok: true }` stub is what let the .423 outage ship green.
|
|
96
102
|
if (attempts === 1)
|
|
97
|
-
return
|
|
98
|
-
return new Promise((resolve) => { release = () => resolve(
|
|
103
|
+
return undefined;
|
|
104
|
+
return new Promise((resolve) => { release = () => resolve(undefined); });
|
|
99
105
|
};
|
|
100
106
|
await receiver.start();
|
|
101
107
|
receiver.client.emit('disconnected');
|
|
@@ -130,8 +136,11 @@ async function delaysFor(random, windowMs = 220) {
|
|
|
130
136
|
let attempts = 0;
|
|
131
137
|
receiver.client.start = async () => {
|
|
132
138
|
attempts += 1;
|
|
139
|
+
// The real SDK fulfills `undefined` after a successful hello, despite its
|
|
140
|
+
// declared AppsConnectionsOpenResponse return type. Stub the world, not our
|
|
141
|
+
// idea of it: a `{ ok: true }` stub is what let the .423 outage ship green.
|
|
133
142
|
if (attempts === 1)
|
|
134
|
-
return
|
|
143
|
+
return undefined;
|
|
135
144
|
throw new Error('transient');
|
|
136
145
|
};
|
|
137
146
|
await receiver.start();
|
|
@@ -178,3 +187,30 @@ test('a fatal error during initial start() is loud and rejects', async () => {
|
|
|
178
187
|
assert.equal(attempts, 1, 'a fatal auth error must not be retried');
|
|
179
188
|
assert.ok(errors.some((m) => /failed permanently/i.test(m)), `startup give-up must be loud, saw: ${JSON.stringify(errors)}`);
|
|
180
189
|
});
|
|
190
|
+
// The class boundary. `start()` is declared Promise<AppsConnectionsOpenResponse>
|
|
191
|
+
// (Bolt's signature, un-widenable in an override) but genuinely resolves the
|
|
192
|
+
// SDK's `undefined` on success. Nothing may branch on that value's truthiness.
|
|
193
|
+
// A comment rots in one refactor; this goes red instead.
|
|
194
|
+
test('start() resolves undefined, and the receiver is still connected (no truthiness gate)', async () => {
|
|
195
|
+
const receiver = new ResilientSocketModeReceiver({
|
|
196
|
+
appToken: 'xapp-test',
|
|
197
|
+
reconnectDelayMs: 2,
|
|
198
|
+
runtimeLogger: { log() { }, warn() { }, error() { } },
|
|
199
|
+
});
|
|
200
|
+
receiver.client.disconnect = async () => { };
|
|
201
|
+
let starts = 0;
|
|
202
|
+
receiver.client.start = async () => {
|
|
203
|
+
starts += 1;
|
|
204
|
+
return undefined;
|
|
205
|
+
};
|
|
206
|
+
const result = await receiver.start();
|
|
207
|
+
assert.equal(result, undefined, 'start() must surface the SDK\'s undefined, not invent a payload');
|
|
208
|
+
assert.equal(starts, 1);
|
|
209
|
+
// The only observable proof that `undefined` was treated as CONNECTED rather
|
|
210
|
+
// than as "stopped": the receiver now reconnects on a disconnect, which
|
|
211
|
+
// onDisconnected only does when `started` is true.
|
|
212
|
+
receiver.client.emit('disconnected');
|
|
213
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
214
|
+
assert.ok(starts > 1, `an undefined success must mark the receiver started; saw ${starts} start() calls`);
|
|
215
|
+
await receiver.stop();
|
|
216
|
+
});
|