@sealant/sdk-next 0.40.0-next.981 → 0.40.0-next.982
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,5 +1,5 @@
|
|
|
1
1
|
import { controlPlaneEventSchema } from "@sealant/api-contracts";
|
|
2
|
-
import { Deferred, Duration, Effect, Layer, Queue, Random, Ref, Schema, Stream } from "effect";
|
|
2
|
+
import { Cause, Deferred, Duration, Effect, Layer, Queue, Random, Ref, Schema, Stream, } from "effect";
|
|
3
3
|
import { SealantConfig } from "../config.js";
|
|
4
4
|
import { currentOwner } from "../context.js";
|
|
5
5
|
import { SseClient } from "../http.js";
|
|
@@ -70,11 +70,16 @@ export const make = Effect.gen(function* () {
|
|
|
70
70
|
});
|
|
71
71
|
// A cut before the first subscription settles the wait for it too: the caller reads on its
|
|
72
72
|
// poll until a reconnect subscribes, and that `subscribed` wakes it.
|
|
73
|
-
const
|
|
74
|
-
yield* follow(filter, { onCut }).pipe(Stream.runForEach(onEvent),
|
|
73
|
+
const unpushed = Effect.andThen(Ref.set(pushed, false), Deferred.succeed(settled, undefined));
|
|
74
|
+
yield* follow(filter, { onCut: unpushed }).pipe(Stream.runForEach(onEvent),
|
|
75
75
|
// Refused (an older control plane, a key that may not read events): no push channel, so
|
|
76
76
|
// every wait reads on its `poll`. Nothing to report: the wait still works.
|
|
77
|
-
Effect.catchTag("SealantStreamRefusedError", () =>
|
|
77
|
+
Effect.catchTag("SealantStreamRefusedError", () => unpushed),
|
|
78
|
+
// Anything else that ends the follower (a defect) leaves the waits on their `poll` too,
|
|
79
|
+
// never on a push channel that is gone. Logged, since nothing else will say so.
|
|
80
|
+
Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)
|
|
81
|
+
? Effect.failCause(cause)
|
|
82
|
+
: Effect.logWarning("Sealant event push stopped; waits read on their poll", cause).pipe(Effect.andThen(unpushed))), Effect.forkScoped);
|
|
78
83
|
yield* Deferred.await(settled).pipe(Effect.timeoutOption(SUBSCRIBE_WAIT));
|
|
79
84
|
// The caller reads next: whatever woke us before that read is already in it.
|
|
80
85
|
yield* Queue.clear(wakes);
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* `resize` and `signal` carry on.
|
|
22
22
|
*/
|
|
23
23
|
import { sessionAttachServerFrameSchema, } from "@sealant/api-contracts";
|
|
24
|
-
import { Deferred, Duration, Effect, Option, Queue, Random, Redacted, Ref, Schema, Stream, } from "effect";
|
|
24
|
+
import { Cause, Deferred, Duration, Effect, Option, Queue, Random, Redacted, Ref, Schema, Stream, } from "effect";
|
|
25
25
|
import { Socket } from "effect/socket";
|
|
26
26
|
import { SessionAttachError, SessionEndedError } from "../errors.js";
|
|
27
27
|
const decodeServerFrame = Schema.decodeUnknownOption(Schema.fromJsonString(sessionAttachServerFrameSchema));
|
|
@@ -165,7 +165,18 @@ export const attachSession = (target) => Effect.gen(function* () {
|
|
|
165
165
|
yield* Effect.sleep(yield* reconnectDelay(attempt));
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
|
-
|
|
168
|
+
// A defect ends the pump without ending `output`, `exit` or `opened`: it fails all three, so
|
|
169
|
+
// nobody waits on an attachment whose socket is no longer read.
|
|
170
|
+
const failedUnexpectedly = (cause) => {
|
|
171
|
+
if (Cause.hasInterruptsOnly(cause))
|
|
172
|
+
return Effect.failCause(cause);
|
|
173
|
+
const error = new SessionAttachError({
|
|
174
|
+
sessionId,
|
|
175
|
+
message: `The attachment to session ${sessionId} failed unexpectedly; attach again.`,
|
|
176
|
+
});
|
|
177
|
+
return Effect.andThen(Deferred.fail(opened, error), failWith(error));
|
|
178
|
+
};
|
|
179
|
+
yield* Effect.forkScoped(pump.pipe(Effect.catchCause(failedUnexpectedly)));
|
|
169
180
|
yield* Deferred.await(opened);
|
|
170
181
|
/** Sends a frame, or fails at once once the session has ended or the attachment failed. */
|
|
171
182
|
const send = (frame) => Effect.raceFirst(writer.write(frame).pipe(Effect.mapError((cause) => new SessionAttachError({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealant/sdk-next",
|
|
3
|
-
"version": "0.40.0-next.
|
|
3
|
+
"version": "0.40.0-next.982",
|
|
4
4
|
"description": "The fluent public SDK for Sealant — create a workspace, run a harness, replay the record.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.
|
|
29
|
+
"@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.982"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"effect": "^4.0.5"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "e3e49f02fd6d8e7edee51078e3e2dde1ae04d6b0",
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
}
|