@livestore/common-cf 0.5.0-dev.0 → 0.5.0
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/dist/.tsbuildinfo +1 -1
- package/dist/declare/mod.js +1 -1
- package/dist/do-rpc/client.d.ts +8 -0
- package/dist/do-rpc/client.d.ts.map +1 -1
- package/dist/do-rpc/client.js +67 -37
- package/dist/do-rpc/client.js.map +1 -1
- package/dist/do-rpc/client.test.js +97 -7
- package/dist/do-rpc/client.test.js.map +1 -1
- package/dist/do-rpc/mod.d.ts +1 -1
- package/dist/do-rpc/mod.d.ts.map +1 -1
- package/dist/do-rpc/mod.js +2 -2
- package/dist/do-rpc/mod.js.map +1 -1
- package/dist/do-rpc/rpc.test.js +2 -2
- package/dist/do-rpc/rpc.test.js.map +1 -1
- package/dist/do-rpc/server.d.ts +4 -3
- package/dist/do-rpc/server.d.ts.map +1 -1
- package/dist/do-rpc/server.js +55 -63
- package/dist/do-rpc/server.js.map +1 -1
- package/dist/do-rpc/test-fixtures/rpc-schema.d.ts +16 -16
- package/dist/do-rpc/test-fixtures/worker.d.ts.map +1 -1
- package/dist/do-rpc/test-fixtures/worker.js +1 -1
- package/dist/mod.js +3 -3
- package/dist/ws-rpc/test-fixtures/rpc-schema.d.ts +16 -16
- package/dist/ws-rpc/test-fixtures/worker.d.ts.map +1 -1
- package/dist/ws-rpc/test-fixtures/worker.js +2 -2
- package/dist/ws-rpc/ws-rpc-server.d.ts +8 -2
- package/dist/ws-rpc/ws-rpc-server.d.ts.map +1 -1
- package/dist/ws-rpc/ws-rpc-server.js +45 -13
- package/dist/ws-rpc/ws-rpc-server.js.map +1 -1
- package/dist/ws-rpc/ws-rpc.test.js +1 -1
- package/dist/ws-rpc/ws-rpc.test.js.map +1 -1
- package/package.json +28 -28
- package/src/do-rpc/README.md +2 -2
- package/src/do-rpc/client.test.ts +148 -7
- package/src/do-rpc/client.ts +94 -53
- package/src/do-rpc/mod.ts +1 -1
- package/src/do-rpc/rpc.test.ts +1 -1
- package/src/do-rpc/server.ts +84 -67
- package/src/ws-rpc/ws-rpc-server.ts +78 -12
package/dist/do-rpc/server.js
CHANGED
|
@@ -1,44 +1,33 @@
|
|
|
1
|
-
import { Effect, Exit, Headers, Option, Rpc, RpcMessage, RpcSchema, RpcSerialization, Result, Schema, SchemaIssue, Stream, } from '@livestore/utils/effect';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* as `unknown`, which surfaces as `unknown` in the requirements channel of `encode/decodeUnknownEffect`
|
|
6
|
-
* (anyUnknownInErrorContext / TS377030). Assert the true `never` services in ONE place.
|
|
7
|
-
*
|
|
8
|
-
* TODO(effect): revisit if a cleaner/idiomatic API lands — https://github.com/Effect-TS/effect/issues/6489
|
|
9
|
-
*/
|
|
10
|
-
const erasedJsonCodec = (schema) =>
|
|
1
|
+
import { Effect, Exit, Fiber, Headers, Option, Rpc, RpcMessage, RpcSchema, RpcSerialization, Result, Schema, SchemaIssue, Stream, } from '@livestore/utils/effect';
|
|
2
|
+
const isEncodedRpcMessage = Schema.is(RpcMessage.EncodedSchema);
|
|
3
|
+
const isRequestEncoded = (message) => isEncodedRpcMessage(message) === true && message._tag === 'Request';
|
|
4
|
+
const erasedCodec = (codecFor, schema) =>
|
|
11
5
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- erased RPC data schemas require no codec services
|
|
12
|
-
|
|
6
|
+
codecFor(schema);
|
|
7
|
+
const schemaBinarySerialization = RpcSerialization.RpcSerialization.pipe(Effect.provide(RpcSerialization.layerSchemaBinary()));
|
|
8
|
+
const encodeBytes = (parser, value) => {
|
|
9
|
+
const encoded = parser.encode(value);
|
|
10
|
+
if (encoded instanceof Uint8Array === false) {
|
|
11
|
+
throw new TypeError('SchemaBinary RPC serialization did not produce bytes');
|
|
12
|
+
}
|
|
13
|
+
if (encoded.buffer instanceof ArrayBuffer === false) {
|
|
14
|
+
throw new TypeError('SchemaBinary RPC serialization produced shared bytes');
|
|
15
|
+
}
|
|
16
|
+
return new Uint8Array(encoded.buffer, encoded.byteOffset, encoded.byteLength);
|
|
17
|
+
};
|
|
13
18
|
/**
|
|
14
19
|
* Construct a Durable Object RPC handler from an `RpcGroup`.
|
|
15
20
|
* This is the DO equivalent of `RpcServer.toWebHandler`.
|
|
16
21
|
*/
|
|
17
22
|
export const toDurableObjectHandler = (group, options) => (serializedPayload) => Effect.gen(function* () {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
// Handle potential nested array from client serialization
|
|
22
|
-
let requests;
|
|
23
|
-
if (Array.isArray(decoded) === true && decoded.length === 1 && Array.isArray(decoded[0]) === true) {
|
|
24
|
-
// Double-wrapped array [[{...}]] -> [{...}]
|
|
25
|
-
requests = decoded[0];
|
|
26
|
-
}
|
|
27
|
-
else if (Array.isArray(decoded) === true) {
|
|
28
|
-
// Single array [{...}]
|
|
29
|
-
requests = decoded;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
requests = [];
|
|
33
|
-
}
|
|
23
|
+
const serialization = yield* schemaBinarySerialization;
|
|
24
|
+
const parser = serialization.makeUnsafe();
|
|
25
|
+
const requests = parser.decode(serializedPayload).filter(isRequestEncoded);
|
|
34
26
|
// Get the context with handlers
|
|
35
27
|
const context = yield* Effect.context();
|
|
36
28
|
// Process each request
|
|
37
29
|
const responses = [];
|
|
38
30
|
for (const request of requests) {
|
|
39
|
-
if (request._tag !== 'Request') {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
31
|
const requestId = RpcMessage.RequestId(request.id);
|
|
43
32
|
// Find the RPC handler
|
|
44
33
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- RpcGroup.requests map returns Rpc.Any; narrowing to AnyWithProps for property access
|
|
@@ -53,14 +42,12 @@ export const toDurableObjectHandler = (group, options) => (serializedPayload) =>
|
|
|
53
42
|
});
|
|
54
43
|
continue;
|
|
55
44
|
}
|
|
56
|
-
const payloadResult = yield* Schema.decodeUnknownEffect(
|
|
45
|
+
const payloadResult = yield* Schema.decodeUnknownEffect(erasedCodec(serialization.codecFor, rpc.payloadSchema))(request.payload).pipe(Effect.provideContext(entry.context), Effect.result);
|
|
57
46
|
if (Result.isFailure(payloadResult) === true) {
|
|
58
|
-
// Request payloads are encoded with the JSON codec by Effect's RPC client. Decode them
|
|
59
|
-
// before dispatch so JSON-only representations such as `null` become their schema values.
|
|
60
47
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- Rpc.exitSchema requires AnyWithProps; type narrowing already done above
|
|
61
48
|
const exitSchema = Rpc.exitSchema(rpc);
|
|
62
49
|
const rawExit = Exit.die(SchemaIssue.makeFormatterDefault()(payloadResult.failure.issue));
|
|
63
|
-
const encodedExit = yield* Schema.encodeUnknownEffect(
|
|
50
|
+
const encodedExit = yield* Schema.encodeUnknownEffect(erasedCodec(serialization.codecFor, exitSchema))(rawExit).pipe(Effect.provideContext(entry.context));
|
|
64
51
|
responses.push({
|
|
65
52
|
_tag: 'Exit',
|
|
66
53
|
requestId,
|
|
@@ -73,7 +60,7 @@ export const toDurableObjectHandler = (group, options) => (serializedPayload) =>
|
|
|
73
60
|
const isStream = RpcSchema.isStreamSchema(rpc.successSchema);
|
|
74
61
|
// For streaming RPCs with only one request, return ReadableStream directly
|
|
75
62
|
if (isStream === true && requests.length === 1) {
|
|
76
|
-
return yield* createStreamingResponse(rpc, entry, requestId, payload, parser, options.layer);
|
|
63
|
+
return yield* createStreamingResponse(rpc, entry, requestId, payload, parser, serialization.codecFor, options.layer);
|
|
77
64
|
}
|
|
78
65
|
// Execute the handler
|
|
79
66
|
const result = yield* Effect.gen(function* () {
|
|
@@ -101,7 +88,7 @@ export const toDurableObjectHandler = (group, options) => (serializedPayload) =>
|
|
|
101
88
|
if (exitSchema !== undefined) {
|
|
102
89
|
// Use schema encoding for proper serialization
|
|
103
90
|
const rawExit = Exit.succeed(value);
|
|
104
|
-
encodedExit = yield* Schema.encodeUnknownEffect(
|
|
91
|
+
encodedExit = yield* Schema.encodeUnknownEffect(erasedCodec(serialization.codecFor, exitSchema))(rawExit);
|
|
105
92
|
}
|
|
106
93
|
else {
|
|
107
94
|
// Fallback to direct exit
|
|
@@ -121,7 +108,7 @@ export const toDurableObjectHandler = (group, options) => (serializedPayload) =>
|
|
|
121
108
|
if (exitSchema !== undefined) {
|
|
122
109
|
// Use schema encoding for proper serialization
|
|
123
110
|
const rawExit = Exit.failCause(cause);
|
|
124
|
-
encodedExit = yield* Schema.encodeUnknownEffect(
|
|
111
|
+
encodedExit = yield* Schema.encodeUnknownEffect(erasedCodec(serialization.codecFor, exitSchema))(rawExit);
|
|
125
112
|
}
|
|
126
113
|
else {
|
|
127
114
|
// Fallback to direct exit
|
|
@@ -136,31 +123,30 @@ export const toDurableObjectHandler = (group, options) => (serializedPayload) =>
|
|
|
136
123
|
}));
|
|
137
124
|
responses.push(result);
|
|
138
125
|
}
|
|
139
|
-
|
|
140
|
-
const encoded = parser.encode(responses);
|
|
141
|
-
return encoded;
|
|
126
|
+
return encodeBytes(parser, responses);
|
|
142
127
|
}).pipe(Effect.provide(options.layer), Effect.scoped, Effect.orDie);
|
|
143
128
|
/** Out-of-band RPC stream response emission back to the caller DO */
|
|
144
|
-
export const emitStreamResponse = Effect.fn('do-rpc/emitStreamResponse')(function* ({ callerContext, env, requestId, storeId, values, }) {
|
|
129
|
+
export const emitStreamResponse = Effect.fn('do-rpc/emitStreamResponse')(function* ({ callerContext, env, requestId, schema, storeId, values, }) {
|
|
145
130
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- CF worker env bindings are typed as Record<string, any>; narrowing to known DO namespace
|
|
146
131
|
const clientDoNamespace = env[callerContext.bindingName];
|
|
147
132
|
if (clientDoNamespace === undefined) {
|
|
148
133
|
throw new Error(`Client DO namespace not found: ${callerContext.bindingName}`);
|
|
149
134
|
}
|
|
150
135
|
const clientDo = clientDoNamespace.get(clientDoNamespace.idFromString(callerContext.durableObjectId));
|
|
151
|
-
const
|
|
152
|
-
const parser =
|
|
136
|
+
const serialization = yield* schemaBinarySerialization;
|
|
137
|
+
const parser = serialization.makeUnsafe();
|
|
138
|
+
const encodedValues = yield* Schema.encodeUnknownEffect(erasedCodec(serialization.codecFor, Schema.NonEmptyArray(schema)))(values);
|
|
139
|
+
const res = { _tag: 'Chunk', requestId, values: encodedValues };
|
|
153
140
|
// Native Cloudflare RPC rejects schema values with custom prototypes. Keep the callback
|
|
154
141
|
// boundary clone-safe by sending the already-encoded Effect RPC message as bytes.
|
|
155
|
-
|
|
156
|
-
const serializedRes = parser.encode(res);
|
|
142
|
+
const serializedRes = encodeBytes(parser, res);
|
|
157
143
|
yield* Effect.tryPromise(() => clientDo.syncUpdateRpc(serializedRes, storeId));
|
|
158
144
|
});
|
|
159
145
|
/**
|
|
160
146
|
* Creates a ReadableStream response for streaming RPCs.
|
|
161
147
|
* This converts an Effect Stream into a ReadableStream of serialized RPC messages.
|
|
162
148
|
*/
|
|
163
|
-
const createStreamingResponse = (rpc, entry, requestId, payload, parser, layer) => Effect.gen(function* () {
|
|
149
|
+
const createStreamingResponse = (rpc, entry, requestId, payload, parser, codecFor, layer) => Effect.gen(function* () {
|
|
164
150
|
// Execute the handler to get the stream
|
|
165
151
|
const handlerResult = entry.handler(payload, {
|
|
166
152
|
client: new Rpc.ServerClient(0), // TODO: add proper clientId if needed
|
|
@@ -171,9 +157,12 @@ const createStreamingResponse = (rpc, entry, requestId, payload, parser, layer)
|
|
|
171
157
|
rpc,
|
|
172
158
|
});
|
|
173
159
|
const effectOrStream = Rpc.isWrapper(handlerResult) === true ? handlerResult.value : handlerResult;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
160
|
+
// @effect-diagnostics-next-line anyUnknownInErrorContext:off -- dynamically dispatched handlers have an unknown error; orDie converts it to a defect handled by the downstream catchCause
|
|
161
|
+
const result = Effect.isEffect(effectOrStream) === true ? yield* Effect.orDie(effectOrStream) : effectOrStream;
|
|
162
|
+
if (Stream.isStream(result) === false) {
|
|
163
|
+
return yield* Effect.die(`Streaming RPC ${rpc._tag} did not produce a Stream`);
|
|
164
|
+
}
|
|
165
|
+
const stream = result;
|
|
177
166
|
// Get the stream schemas for proper chunk-level encoding
|
|
178
167
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- Rpc.Handler doesn't expose successSchema publicly; see https://github.com/Effect-TS/effect/issues/6064
|
|
179
168
|
const streamSchemas = RpcSchema.isStreamSchema(rpc.successSchema) === true
|
|
@@ -183,9 +172,11 @@ const createStreamingResponse = (rpc, entry, requestId, payload, parser, layer)
|
|
|
183
172
|
})
|
|
184
173
|
: Option.none();
|
|
185
174
|
const arrayEncoder = Option.isSome(streamSchemas) === true
|
|
186
|
-
? Schema.encodeUnknownEffect(
|
|
187
|
-
: Schema.encodeUnknownEffect(
|
|
175
|
+
? Schema.encodeUnknownEffect(erasedCodec(codecFor, Schema.NonEmptyArray(streamSchemas.value.success)))
|
|
176
|
+
: Schema.encodeUnknownEffect(erasedCodec(codecFor, Schema.NonEmptyArray(Schema.Any)));
|
|
188
177
|
// Convert stream to ReadableStream
|
|
178
|
+
let producer;
|
|
179
|
+
let cancelled = false;
|
|
189
180
|
const readableStream = new ReadableStream({
|
|
190
181
|
start(controller) {
|
|
191
182
|
// Run the stream and send chunks + final exit
|
|
@@ -201,42 +192,43 @@ const createStreamingResponse = (rpc, entry, requestId, payload, parser, layer)
|
|
|
201
192
|
requestId,
|
|
202
193
|
values: encodedValues,
|
|
203
194
|
};
|
|
204
|
-
|
|
205
|
-
const serialized = parser.encode([chunkMessage]);
|
|
206
|
-
controller.enqueue(serialized);
|
|
195
|
+
controller.enqueue(encodeBytes(parser, [chunkMessage]));
|
|
207
196
|
}));
|
|
208
197
|
// Send final exit message with proper schema encoding
|
|
209
198
|
const rawExit = Exit.void;
|
|
210
199
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- Rpc.exitSchema requires AnyWithProps; type narrowing already done above
|
|
211
200
|
const exitSchema = Rpc.exitSchema(rpc);
|
|
212
|
-
const encodedExit = yield* Schema.encodeUnknownEffect(
|
|
201
|
+
const encodedExit = yield* Schema.encodeUnknownEffect(erasedCodec(codecFor, exitSchema))(rawExit);
|
|
213
202
|
const exitMessage = {
|
|
214
203
|
_tag: 'Exit',
|
|
215
204
|
requestId,
|
|
216
205
|
exit: encodedExit,
|
|
217
206
|
};
|
|
218
|
-
|
|
219
|
-
const exitSerialized = parser.encode([exitMessage]);
|
|
220
|
-
controller.enqueue(exitSerialized);
|
|
207
|
+
controller.enqueue(encodeBytes(parser, [exitMessage]));
|
|
221
208
|
controller.close();
|
|
222
209
|
}).pipe(Effect.catchCause((cause) => Effect.gen(function* () {
|
|
210
|
+
if (cancelled === true)
|
|
211
|
+
return;
|
|
223
212
|
// Send error exit with proper schema encoding
|
|
224
213
|
const rawExit = Exit.failCause(cause);
|
|
225
214
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- Rpc.exitSchema requires AnyWithProps; type narrowing already done above
|
|
226
215
|
const exitSchema = Rpc.exitSchema(rpc);
|
|
227
|
-
const encodedExit = yield* Schema.encodeUnknownEffect(
|
|
216
|
+
const encodedExit = yield* Schema.encodeUnknownEffect(erasedCodec(codecFor, exitSchema))(rawExit);
|
|
228
217
|
const exitMessage = {
|
|
229
218
|
_tag: 'Exit',
|
|
230
219
|
requestId,
|
|
231
220
|
exit: encodedExit,
|
|
232
221
|
};
|
|
233
|
-
|
|
234
|
-
const exitSerialized = parser.encode([exitMessage]);
|
|
235
|
-
controller.enqueue(exitSerialized);
|
|
222
|
+
controller.enqueue(encodeBytes(parser, [exitMessage]));
|
|
236
223
|
controller.close();
|
|
237
224
|
})));
|
|
238
225
|
// Run the stream processing
|
|
239
|
-
runStream.pipe(Effect.provide(layer), Effect.scoped, Effect.tapCauseLogPretty, (_) => _, Effect.
|
|
226
|
+
producer = runStream.pipe(Effect.provide(layer), Effect.scoped, Effect.tapCauseLogPretty, (_) => _, Effect.runFork);
|
|
227
|
+
},
|
|
228
|
+
cancel() {
|
|
229
|
+
cancelled = true;
|
|
230
|
+
// @effect-diagnostics-next-line runEffectInsideEffect:off -- native stream callback runs outside Effect; interruption needs no services
|
|
231
|
+
return producer === undefined ? undefined : Effect.runPromise(Fiber.interrupt(producer));
|
|
240
232
|
},
|
|
241
233
|
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- bridging standard Web API ReadableStream to Cloudflare Worker ReadableStream type
|
|
242
234
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/do-rpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EAEP,MAAM,EAEN,GAAG,EAEH,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,WAAW,EAEX,MAAM,GACP,MAAM,yBAAyB,CAAA;AAIhC
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/do-rpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EAEP,MAAM,EAEN,GAAG,EAEH,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,WAAW,EAEX,MAAM,GACP,MAAM,yBAAyB,CAAA;AAIhC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;AAE/D,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAwC,EAAE,CAClF,mBAAmB,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,CAAA;AAErE,MAAM,WAAW,GAAG,CAAC,QAAmC,EAAE,MAAkB,EAAE,EAAE;AAC9E,4HAA4H;AAC5H,QAAQ,CAAC,MAAsD,CAAC,CAAA;AAElE,MAAM,yBAAy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G,CAAC,UAAU,CAAC,GAAU,CAAe,CAAA;gBAC3D,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;gBAEjG,MAAM,WAAW,GAAG;oBAClB,IAAI,EAAE,MAAe;oBACrB,SAAS;oBACT,IAAI,EAAE,WAAW;iBAClB,CAAA;gBAED,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;gBACtD,UAAU,CAAC,KAAK,EAAE,CAAA;YACpB,CAAC,CAAC,CACH,CACF,CAAA;YAED,4BAA4B;YAC5B,QAAQ,GAAG,SAAS,CAAC,IAAI,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EACrB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,iBAAiB,EACxB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAwB,EAC/B,MAAM,CAAC,OAAO,CACf,CAAA;QACH,CAAC;QACD,MAAM;YACJ,SAAS,GAAG,IAAI,CAAA;YAChB,wIAAwI;YACxI,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC1F,CAAC;QACD,4JAA4J;KAC7J,CAAkC,CAAA;IAEnC,kFAAkF;IAElF,OAAO,cAAc,CAAA;AACvB,CAAC,CAAC,CAAA"}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
2
|
-
declare const TestRpcs_base: RpcGroup.RpcGroup<Rpc.Rpc<"
|
|
3
|
-
readonly message: Schema.String;
|
|
4
|
-
}>, Schema.Struct<{
|
|
5
|
-
readonly response: Schema.String;
|
|
6
|
-
}>, Schema.Never, never, never> | Rpc.Rpc<"Echo", Schema.Struct<{
|
|
7
|
-
readonly text: Schema.String;
|
|
8
|
-
}>, Schema.Struct<{
|
|
9
|
-
readonly echo: Schema.String;
|
|
10
|
-
}>, Schema.Never, never, never> | Rpc.Rpc<"Add", Schema.Struct<{
|
|
2
|
+
declare const TestRpcs_base: RpcGroup.RpcGroup<Rpc.Rpc<"Add", Schema.Struct<{
|
|
11
3
|
readonly a: Schema.Finite;
|
|
12
4
|
readonly b: Schema.Finite;
|
|
13
5
|
}>, Schema.Struct<{
|
|
@@ -16,22 +8,30 @@ declare const TestRpcs_base: RpcGroup.RpcGroup<Rpc.Rpc<"Ping", Schema.Struct<{
|
|
|
16
8
|
readonly message: Schema.String;
|
|
17
9
|
}>, Schema.Struct<{
|
|
18
10
|
readonly never: Schema.String;
|
|
11
|
+
}>, Schema.Never, never, never> | Rpc.Rpc<"Echo", Schema.Struct<{
|
|
12
|
+
readonly text: Schema.String;
|
|
13
|
+
}>, Schema.Struct<{
|
|
14
|
+
readonly echo: Schema.String;
|
|
19
15
|
}>, Schema.Never, never, never> | Rpc.Rpc<"Fail", Schema.Struct<{
|
|
20
16
|
readonly message: Schema.String;
|
|
21
17
|
}>, Schema.Struct<{
|
|
22
18
|
readonly never: Schema.String;
|
|
23
|
-
}>, Schema.String, never, never> | Rpc.Rpc<"
|
|
19
|
+
}>, Schema.String, never, never> | Rpc.Rpc<"Ping", Schema.Struct<{
|
|
20
|
+
readonly message: Schema.String;
|
|
21
|
+
}>, Schema.Struct<{
|
|
22
|
+
readonly response: Schema.String;
|
|
23
|
+
}>, Schema.Never, never, never> | Rpc.Rpc<"Stream", Schema.Struct<{}>, import("effect/rpc/RpcSchema").Stream<Schema.Struct<{
|
|
24
24
|
readonly maybeNumber: Schema.Option<Schema.Finite>;
|
|
25
|
-
}>, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"
|
|
26
|
-
readonly count: Schema.Finite;
|
|
27
|
-
readonly errorAfter: Schema.Finite;
|
|
28
|
-
}>, import("effect/unstable/rpc/RpcSchema").Stream<Schema.Finite, Schema.String>, Schema.Never, never, never> | Rpc.Rpc<"StreamDefect", Schema.Struct<{
|
|
25
|
+
}>, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"StreamBugScenarioDoClient", Schema.Struct<{}>, Schema.Finite, Schema.Never, never, never> | Rpc.Rpc<"StreamBugScenarioDoServer", Schema.Struct<{}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"StreamDefect", Schema.Struct<{
|
|
29
26
|
readonly count: Schema.Finite;
|
|
30
27
|
readonly defectAfter: Schema.Finite;
|
|
31
|
-
}>, import("effect/
|
|
28
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"StreamError", Schema.Struct<{
|
|
29
|
+
readonly count: Schema.Finite;
|
|
30
|
+
readonly errorAfter: Schema.Finite;
|
|
31
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.String>, Schema.Never, never, never> | Rpc.Rpc<"StreamInterruptible", Schema.Struct<{
|
|
32
32
|
readonly delay: Schema.Finite;
|
|
33
33
|
readonly interruptAfterCount: Schema.Finite;
|
|
34
|
-
}>, import("effect/
|
|
34
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.Never>, Schema.Never, never, never>>;
|
|
35
35
|
export declare class TestRpcs extends TestRpcs_base {
|
|
36
36
|
}
|
|
37
37
|
export type TestRpcsI = RpcGroup.Rpcs<typeof TestRpcs>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/do-rpc/test-fixtures/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAiBlD,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAA;CAC1D;AAED,qBAAa,oBAAqB,SAAQ,aAAa;IAC5C,sBAAsB,EAA6B,KAAK,CAAA;IAE3D,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/do-rpc/test-fixtures/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAiBlD,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAA;CAC1D;AAED,qBAAa,oBAAqB,SAAQ,aAAa;IAC5C,sBAAsB,EAA6B,KAAK,CAAA;IAE3D,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CA2C5C;CACF;;IAGO,KAAK,UAAU,OAAO,OAAO,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { DurableObject } from 'cloudflare:workers';
|
|
3
3
|
import { layerProtocolDurableObject, toDurableObjectHandler } from '@livestore/common-cf';
|
|
4
4
|
import { Effect, HttpEffect, Layer, Option, RpcClient, RpcSerialization, RpcServer, Schedule, Stream, } from '@livestore/utils/effect';
|
|
5
|
-
import { TestRpcs } from
|
|
5
|
+
import { TestRpcs } from './rpc-schema.js';
|
|
6
6
|
export class TestRpcDurableObject extends DurableObject {
|
|
7
7
|
__DURABLE_OBJECT_BRAND = 'TestRpcDurableObject';
|
|
8
8
|
async rpc(payload) {
|
package/dist/mod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './do-rpc/mod.js';
|
|
2
|
+
export * from './helper.js';
|
|
3
|
+
export * from './ws-rpc/ws-rpc-server.js';
|
|
4
4
|
//# sourceMappingURL=mod.js.map
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
2
|
-
declare const TestRpcs_base: RpcGroup.RpcGroup<Rpc.Rpc<"
|
|
3
|
-
readonly message: Schema.String;
|
|
4
|
-
}>, Schema.Struct<{
|
|
5
|
-
readonly response: Schema.String;
|
|
6
|
-
}>, Schema.Never, never, never> | Rpc.Rpc<"Echo", Schema.Struct<{
|
|
7
|
-
readonly text: Schema.String;
|
|
8
|
-
}>, Schema.Struct<{
|
|
9
|
-
readonly echo: Schema.String;
|
|
10
|
-
}>, Schema.Never, never, never> | Rpc.Rpc<"Add", Schema.Struct<{
|
|
2
|
+
declare const TestRpcs_base: RpcGroup.RpcGroup<Rpc.Rpc<"Add", Schema.Struct<{
|
|
11
3
|
readonly a: Schema.Finite;
|
|
12
4
|
readonly b: Schema.Finite;
|
|
13
5
|
}>, Schema.Struct<{
|
|
@@ -16,22 +8,30 @@ declare const TestRpcs_base: RpcGroup.RpcGroup<Rpc.Rpc<"Ping", Schema.Struct<{
|
|
|
16
8
|
readonly message: Schema.String;
|
|
17
9
|
}>, Schema.Struct<{
|
|
18
10
|
readonly never: Schema.String;
|
|
11
|
+
}>, Schema.Never, never, never> | Rpc.Rpc<"Echo", Schema.Struct<{
|
|
12
|
+
readonly text: Schema.String;
|
|
13
|
+
}>, Schema.Struct<{
|
|
14
|
+
readonly echo: Schema.String;
|
|
19
15
|
}>, Schema.Never, never, never> | Rpc.Rpc<"Fail", Schema.Struct<{
|
|
20
16
|
readonly message: Schema.String;
|
|
21
17
|
}>, Schema.Struct<{
|
|
22
18
|
readonly never: Schema.String;
|
|
23
|
-
}>, Schema.String, never, never> | Rpc.Rpc<"
|
|
19
|
+
}>, Schema.String, never, never> | Rpc.Rpc<"Ping", Schema.Struct<{
|
|
20
|
+
readonly message: Schema.String;
|
|
21
|
+
}>, Schema.Struct<{
|
|
22
|
+
readonly response: Schema.String;
|
|
23
|
+
}>, Schema.Never, never, never> | Rpc.Rpc<"Stream", Schema.Struct<{}>, import("effect/rpc/RpcSchema").Stream<Schema.Struct<{
|
|
24
24
|
readonly maybeNumber: Schema.Option<Schema.Finite>;
|
|
25
|
-
}>, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"
|
|
26
|
-
readonly count: Schema.Finite;
|
|
27
|
-
readonly errorAfter: Schema.Finite;
|
|
28
|
-
}>, import("effect/unstable/rpc/RpcSchema").Stream<Schema.Finite, Schema.String>, Schema.Never, never, never> | Rpc.Rpc<"StreamDefect", Schema.Struct<{
|
|
25
|
+
}>, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"StreamDefect", Schema.Struct<{
|
|
29
26
|
readonly count: Schema.Finite;
|
|
30
27
|
readonly defectAfter: Schema.Finite;
|
|
31
|
-
}>, import("effect/
|
|
28
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.Never>, Schema.Never, never, never> | Rpc.Rpc<"StreamError", Schema.Struct<{
|
|
29
|
+
readonly count: Schema.Finite;
|
|
30
|
+
readonly errorAfter: Schema.Finite;
|
|
31
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.String>, Schema.Never, never, never> | Rpc.Rpc<"StreamInterruptible", Schema.Struct<{
|
|
32
32
|
readonly delay: Schema.Finite;
|
|
33
33
|
readonly interruptAfterCount: Schema.Finite;
|
|
34
|
-
}>, import("effect/
|
|
34
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Finite, Schema.Never>, Schema.Never, never, never>>;
|
|
35
35
|
export declare class TestRpcs extends TestRpcs_base {
|
|
36
36
|
}
|
|
37
37
|
export type TestRpcsI = RpcGroup.Rpcs<typeof TestRpcs>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/ws-rpc/test-fixtures/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAQlD,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAA;CAC1D;AAED,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;IAC1D,sBAAsB,EAA6B,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/ws-rpc/test-fixtures/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAQlD,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAA;CAC1D;AAED,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;IAC1D,sBAAsB,EAA6B,KAAK,CAAA;IAEjE,YAAY,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,EA4C9C;IAEc,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAexD;CACF;;IAGO,KAAK,UAAU,OAAO,OAAO,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
2
|
import { DurableObject } from 'cloudflare:workers';
|
|
3
3
|
import { Effect, Layer, Option, RpcServer, Schedule, Stream } from '@livestore/utils/effect';
|
|
4
|
-
import { setupDurableObjectWebSocketRpc } from
|
|
5
|
-
import { TestRpcs } from
|
|
4
|
+
import { setupDurableObjectWebSocketRpc } from '../ws-rpc-server.js';
|
|
5
|
+
import { TestRpcs } from './rpc-schema.js';
|
|
6
6
|
export class TestRpcDurableObject extends DurableObject {
|
|
7
7
|
__DURABLE_OBJECT_BRAND = 'TestRpcDurableObject';
|
|
8
8
|
constructor(state, env) {
|
|
@@ -56,6 +56,10 @@ export interface DurableObjectWebSocketRpcConfig {
|
|
|
56
56
|
rpcLayer: Layer.Layer<never, never, RpcServer.Protocol | WsContext>;
|
|
57
57
|
/** Function to get access to incoming requests */
|
|
58
58
|
onMessage?: (msg: RpcMessage.FromClientEncoded, ws: CfTypes.WebSocket) => void;
|
|
59
|
+
/** Called after a terminal RPC response has been accepted by the serializer. */
|
|
60
|
+
onRequestExit?: (requestId: string | number, ws: CfTypes.WebSocket) => void;
|
|
61
|
+
/** Called after a connection-level RPC defect has been accepted by the serializer. */
|
|
62
|
+
onProtocolDefect?: (ws: CfTypes.WebSocket) => void;
|
|
59
63
|
mainLayer?: Layer.Layer<never>;
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
@@ -118,7 +122,7 @@ export interface DurableObjectWebSocketRpcConfig {
|
|
|
118
122
|
* @see {@link https://developers.cloudflare.com/durable-objects/best-practices/websockets/ Cloudflare WebSocket Best Practices}
|
|
119
123
|
* @see {@link https://effect-ts.github.io/effect/docs/rpc Effect RPC Documentation}
|
|
120
124
|
*/
|
|
121
|
-
export declare const setupDurableObjectWebSocketRpc: ({ doSelf, rpcLayer, webSocketMode, onMessage, mainLayer, }: DurableObjectWebSocketRpcConfig) => {
|
|
125
|
+
export declare const setupDurableObjectWebSocketRpc: ({ doSelf, rpcLayer, webSocketMode, onMessage, onRequestExit, onProtocolDefect, mainLayer, }: DurableObjectWebSocketRpcConfig) => {
|
|
122
126
|
webSocketMessage: (ws: CfTypes.WebSocket, message: string | ArrayBuffer) => void | Promise<void>;
|
|
123
127
|
webSocketClose: (ws: CfTypes.WebSocket, code: number, reason: string, wasClean: boolean) => void | Promise<void>;
|
|
124
128
|
};
|
|
@@ -129,6 +133,8 @@ export interface WsRpcServerArgs {
|
|
|
129
133
|
ws: CfTypes.WebSocket;
|
|
130
134
|
scope: Scope.Scope;
|
|
131
135
|
onMessage?: (message: RpcMessage.FromClientEncoded, ws: CfTypes.WebSocket) => void;
|
|
136
|
+
onRequestExit?: (requestId: string | number, ws: CfTypes.WebSocket) => void;
|
|
137
|
+
onProtocolDefect?: (ws: CfTypes.WebSocket) => void;
|
|
132
138
|
/** Queue for receiving incoming messages from the WebSocket */
|
|
133
139
|
incomingQueue: Queue.Queue<Uint8Array | string>;
|
|
134
140
|
}
|
|
@@ -146,6 +152,6 @@ export interface WsRpcServerArgs {
|
|
|
146
152
|
*
|
|
147
153
|
* @internal This is typically used internally by `setupDurableObjectWebSocketRpc`
|
|
148
154
|
*/
|
|
149
|
-
export declare const layerRpcServerWebsocket: (args: WsRpcServerArgs) => Layer.Layer<
|
|
155
|
+
export declare const layerRpcServerWebsocket: (args: WsRpcServerArgs) => Layer.Layer<RpcServer.Protocol | WsContext, never, RpcSerialization.RpcSerialization>;
|
|
150
156
|
export {};
|
|
151
157
|
//# sourceMappingURL=ws-rpc-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-rpc-server.d.ts","sourceRoot":"","sources":["../../src/ws-rpc/ws-rpc-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,OAAO,EAIP,KAAK,EAEL,KAAK,EAEL,UAAU,EACV,gBAAgB,EAChB,SAAS,
|
|
1
|
+
{"version":3,"file":"ws-rpc-server.d.ts","sourceRoot":"","sources":["../../src/ws-rpc/ws-rpc-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,OAAO,EAIP,KAAK,EAEL,KAAK,EAEL,UAAU,EACV,gBAAgB,EAChB,SAAS,EAET,KAAK,EAEN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAA;;iBAO2B,OAAO,CAAC,SAAS;;AAL1F;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cAA6E;CAAG;AAE/G;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,+CAA+C;IAC/C,MAAM,EAAE,OAAO,CAAC,aAAa,CAAA;IAC7B;;;;OAIG;IACH,aAAa,EAAE,WAAW,GAAG,QAAQ,CAAA;IACrC;;;;;;;;;;;;;;OAcG;IACH,QA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AAO,MAAM,uBAAuB,SAAU,eAAe,0FAI1D,CAAA"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @see {@link https://developers.cloudflare.com/durable-objects/best-practices/websockets/ Cloudflare WebSocket Best Practices}
|
|
16
16
|
*/
|
|
17
17
|
import { notYetImplemented, omitUndefineds } from '@livestore/utils';
|
|
18
|
-
import { Context, Effect, Function, Exit, Layer, Logger, Queue, References, RpcMessage, RpcSerialization, RpcServer, Scope, Stream, } from '@livestore/utils/effect';
|
|
18
|
+
import { Context, Effect, Function, Exit, Layer, Logger, Queue, References, RpcMessage, RpcSerialization, RpcServer, Schema, Scope, Stream, } from '@livestore/utils/effect';
|
|
19
19
|
/**
|
|
20
20
|
* Context service providing access to the current WebSocket.
|
|
21
21
|
* This is useful for reading WebSocket attachment data (e.g., forwarded headers)
|
|
@@ -83,7 +83,7 @@ export class WsContext extends Context.Service()('WsContext') {
|
|
|
83
83
|
* @see {@link https://developers.cloudflare.com/durable-objects/best-practices/websockets/ Cloudflare WebSocket Best Practices}
|
|
84
84
|
* @see {@link https://effect-ts.github.io/effect/docs/rpc Effect RPC Documentation}
|
|
85
85
|
*/
|
|
86
|
-
export const setupDurableObjectWebSocketRpc = ({ doSelf, rpcLayer, webSocketMode, onMessage, mainLayer, }) => {
|
|
86
|
+
export const setupDurableObjectWebSocketRpc = ({ doSelf, rpcLayer, webSocketMode, onMessage, onRequestExit, onProtocolDefect, mainLayer, }) => {
|
|
87
87
|
if (webSocketMode === 'accept') {
|
|
88
88
|
return notYetImplemented(`WebSocket mode 'accept' is not yet implemented`);
|
|
89
89
|
}
|
|
@@ -100,7 +100,7 @@ export const setupDurableObjectWebSocketRpc = ({ doSelf, rpcLayer, webSocketMode
|
|
|
100
100
|
ws,
|
|
101
101
|
scope,
|
|
102
102
|
incomingQueue,
|
|
103
|
-
...omitUndefineds({ onMessage }),
|
|
103
|
+
...omitUndefineds({ onMessage, onRequestExit, onProtocolDefect }),
|
|
104
104
|
}).pipe(Layer.provide(RpcSerialization.layerJson));
|
|
105
105
|
const ServerLive = rpcLayer.pipe(Layer.provide(ProtocolLive));
|
|
106
106
|
yield* Layer.launch(ServerLive).pipe(Effect.tapCauseLogPretty, Effect.forkIn(scope));
|
|
@@ -159,25 +159,49 @@ export const layerRpcServerWebsocket = (args) => Layer.mergeAll(Layer.effect(Rpc
|
|
|
159
159
|
*
|
|
160
160
|
* @internal Used internally by `layerRpcServerWebsocket`
|
|
161
161
|
*/
|
|
162
|
-
const makeSocketProtocol = ({ incomingQueue, scope, ws, onMessage }) => Effect.gen(function* () {
|
|
162
|
+
const makeSocketProtocol = ({ incomingQueue, scope, ws, onMessage, onRequestExit, onProtocolDefect, }) => Effect.gen(function* () {
|
|
163
163
|
const serialization = yield* RpcSerialization.RpcSerialization;
|
|
164
164
|
const disconnects = yield* Queue.unbounded();
|
|
165
|
-
const
|
|
165
|
+
const requestIdsWithSchemas = new Set();
|
|
166
|
+
const interruptedExitEncoded = yield* Schema.encodeUnknownEffect(serialization.codecFor(Schema.Exit(Schema.Void, Schema.Never, Schema.Never)))(Exit.interrupt()).pipe(Effect.orDie);
|
|
167
|
+
const writeRaw = (msg) => Effect.sync(() => ws.send(msg));
|
|
166
168
|
let writeRequest;
|
|
167
169
|
const parser = serialization.makeUnsafe();
|
|
168
170
|
const id = 0;
|
|
169
|
-
const
|
|
171
|
+
const runLifecycleHook = (name, hook) => Effect.sync(hook).pipe(Effect.catchCause((cause) => Effect.logError(`WebSocket RPC ${name} hook failed`, { cause })));
|
|
172
|
+
const writeDefect = (defect) => {
|
|
173
|
+
try {
|
|
174
|
+
const encoded = parser.encode(RpcMessage.ResponseDefectEncoded(defect));
|
|
175
|
+
const responseEffect = encoded === undefined ? Effect.void : Effect.orDie(writeRaw(encoded));
|
|
176
|
+
const onAccepted = Effect.sync(() => requestIdsWithSchemas.clear()).pipe(Effect.andThen(onProtocolDefect !== undefined
|
|
177
|
+
? runLifecycleHook('onProtocolDefect', () => onProtocolDefect(ws))
|
|
178
|
+
: Effect.void));
|
|
179
|
+
return Effect.ensuring(responseEffect, onAccepted);
|
|
180
|
+
}
|
|
181
|
+
catch (cause) {
|
|
182
|
+
return Effect.die(cause);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const writeResponse = (response, onAccepted) => {
|
|
170
186
|
try {
|
|
171
187
|
const encoded = parser.encode(response);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
return Effect.orDie(writeRaw(encoded));
|
|
188
|
+
const responseEffect = encoded === undefined ? Effect.void : Effect.orDie(writeRaw(encoded));
|
|
189
|
+
return onAccepted === undefined ? responseEffect : Effect.ensuring(responseEffect, onAccepted);
|
|
176
190
|
}
|
|
177
191
|
catch (cause) {
|
|
178
|
-
return
|
|
192
|
+
return writeDefect(cause);
|
|
179
193
|
}
|
|
180
194
|
};
|
|
195
|
+
const writeExit = (requestId, exit) => writeResponse({ _tag: 'Exit', requestId, exit }, Effect.sync(() => requestIdsWithSchemas.delete(requestId)).pipe(Effect.andThen(onRequestExit !== undefined
|
|
196
|
+
? runLifecycleHook('onRequestExit', () => onRequestExit(requestId, ws))
|
|
197
|
+
: Effect.void)));
|
|
198
|
+
const write = (response) => {
|
|
199
|
+
if (response._tag === 'Exit')
|
|
200
|
+
return writeExit(response.requestId, response.exit);
|
|
201
|
+
if (response._tag === 'Defect')
|
|
202
|
+
return writeDefect(response.defect);
|
|
203
|
+
return writeResponse(response);
|
|
204
|
+
};
|
|
181
205
|
const protocol = yield* RpcServer.Protocol.make((writeRequest_) => {
|
|
182
206
|
writeRequest = writeRequest_;
|
|
183
207
|
// Start processing messages now that writeRequest is available
|
|
@@ -191,8 +215,15 @@ const makeSocketProtocol = ({ incomingQueue, scope, ws, onMessage }) => Effect.g
|
|
|
191
215
|
while: () => i < decoded.length,
|
|
192
216
|
body: () => {
|
|
193
217
|
const request = decoded[i++];
|
|
194
|
-
if (onMessage !== undefined)
|
|
218
|
+
if (onMessage !== undefined)
|
|
195
219
|
onMessage(request, ws);
|
|
220
|
+
if (request._tag === 'Request') {
|
|
221
|
+
requestIdsWithSchemas.add(request.id);
|
|
222
|
+
}
|
|
223
|
+
else if (request._tag === 'Interrupt' && requestIdsWithSchemas.has(request.requestId) === false) {
|
|
224
|
+
// Effect creates this Exit for an unknown request, but its encoder drops it when hibernation has
|
|
225
|
+
// discarded the request schema.
|
|
226
|
+
return writeExit(request.requestId, interruptedExitEncoded);
|
|
196
227
|
}
|
|
197
228
|
return writeRequest(id, request);
|
|
198
229
|
},
|
|
@@ -200,7 +231,7 @@ const makeSocketProtocol = ({ incomingQueue, scope, ws, onMessage }) => Effect.g
|
|
|
200
231
|
});
|
|
201
232
|
}
|
|
202
233
|
catch (cause) {
|
|
203
|
-
return
|
|
234
|
+
return writeDefect(cause);
|
|
204
235
|
}
|
|
205
236
|
}), Stream.runDrain, Effect.tapCauseLogPretty, Effect.forkIn(scope));
|
|
206
237
|
// Start the message processing
|
|
@@ -217,6 +248,7 @@ const makeSocketProtocol = ({ incomingQueue, scope, ws, onMessage }) => Effect.g
|
|
|
217
248
|
supportsTransferables: false,
|
|
218
249
|
supportsSpanPropagation: true,
|
|
219
250
|
supportsNotifications: true,
|
|
251
|
+
codecFor: serialization.codecFor,
|
|
220
252
|
}));
|
|
221
253
|
});
|
|
222
254
|
return protocol;
|