@livestore/sync-cf 0.0.0-snapshot-5a7afccd98b0dc4ca7500cffd4440d4cf45c832d → 0.0.0-snapshot-aaba95a52ea7fb67ef08b4bf6fa3d7e36e46ebb8
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/cf-worker/do/layer.d.ts +2 -2
- package/dist/cf-worker/do/layer.d.ts.map +1 -1
- package/dist/cf-worker/do/layer.js +3 -3
- package/dist/cf-worker/do/layer.js.map +1 -1
- package/dist/cf-worker/do/pull.d.ts.map +1 -1
- package/dist/cf-worker/do/pull.js +3 -3
- package/dist/cf-worker/do/pull.js.map +1 -1
- package/dist/cf-worker/do/push.js +4 -4
- package/dist/cf-worker/do/push.js.map +1 -1
- package/dist/cf-worker/do/sync-storage.d.ts +5 -5
- package/dist/cf-worker/do/sync-storage.d.ts.map +1 -1
- package/dist/cf-worker/do/sync-storage.js +10 -10
- package/dist/cf-worker/do/sync-storage.js.map +1 -1
- package/dist/cf-worker/worker.d.ts +1 -1
- package/dist/cf-worker/worker.js +4 -4
- package/dist/cf-worker/worker.js.map +1 -1
- package/dist/client/transport/do-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/do-rpc-client.js +6 -4
- package/dist/client/transport/do-rpc-client.js.map +1 -1
- package/dist/client/transport/http-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/http-rpc-client.js +6 -6
- package/dist/client/transport/http-rpc-client.js.map +1 -1
- package/dist/client/transport/ws-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/ws-rpc-client.js +5 -5
- package/dist/client/transport/ws-rpc-client.js.map +1 -1
- package/dist/common/http-rpc-schema.d.ts +2 -2
- package/dist/common/http-rpc-schema.d.ts.map +1 -1
- package/dist/common/http-rpc-schema.js +2 -2
- package/dist/common/http-rpc-schema.js.map +1 -1
- package/package.json +4 -4
- package/src/cf-worker/do/layer.ts +3 -3
- package/src/cf-worker/do/pull.ts +5 -3
- package/src/cf-worker/do/push.ts +4 -4
- package/src/cf-worker/do/sync-storage.ts +20 -20
- package/src/cf-worker/worker.ts +4 -4
- package/src/client/transport/do-rpc-client.ts +6 -4
- package/src/client/transport/http-rpc-client.ts +6 -6
- package/src/client/transport/ws-rpc-client.ts +5 -5
- package/src/common/http-rpc-schema.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError, IsOfflineError, SyncBackend,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, IsOfflineError, SyncBackend, UnexpectedError } from '@livestore/common';
|
|
2
2
|
import { splitChunkBySize } from '@livestore/common/sync';
|
|
3
3
|
import { omit } from '@livestore/utils';
|
|
4
4
|
import { Chunk, Effect, Layer, Option, RpcClient, RpcSerialization, Schedule, Schema, Socket, Stream, SubscriptionRef, UrlParams, } from '@livestore/utils/effect';
|
|
@@ -19,7 +19,7 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
19
19
|
storeId,
|
|
20
20
|
payload,
|
|
21
21
|
transport: 'ws',
|
|
22
|
-
}).pipe(
|
|
22
|
+
}).pipe(UnexpectedError.mapToUnexpectedError);
|
|
23
23
|
const urlParams = UrlParams.fromInput(urlParamsData);
|
|
24
24
|
const wsUrl = `${options.url}?${UrlParams.toString(urlParams)}`;
|
|
25
25
|
const isConnected = yield* SubscriptionRef.make(false);
|
|
@@ -49,7 +49,7 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
49
49
|
const pinger = yield* RpcClient.SocketPinger.pipe(Effect.provide(ctx));
|
|
50
50
|
yield* pinger.ping;
|
|
51
51
|
yield* SubscriptionRef.set(isConnected, true);
|
|
52
|
-
}).pipe(Effect.timeout(pingTimeout), Effect.catchTag('TimeoutException', () => SubscriptionRef.set(isConnected, false)),
|
|
52
|
+
}).pipe(Effect.timeout(pingTimeout), Effect.catchTag('TimeoutException', () => SubscriptionRef.set(isConnected, false)), UnexpectedError.mapToUnexpectedError, Effect.withSpan('ping'));
|
|
53
53
|
const backendIdHelper = yield* SyncBackend.makeBackendIdHelper;
|
|
54
54
|
return SyncBackend.of({
|
|
55
55
|
isConnected,
|
|
@@ -80,7 +80,7 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
80
80
|
maxItems: MAX_PUSH_EVENTS_PER_REQUEST,
|
|
81
81
|
maxBytes: MAX_WS_MESSAGE_BYTES,
|
|
82
82
|
encode: encodePayload,
|
|
83
|
-
}), Effect.mapError((cause) => new InvalidPushError({ cause: new
|
|
83
|
+
}), Effect.mapError((cause) => new InvalidPushError({ cause: new UnexpectedError({ cause }) })));
|
|
84
84
|
for (const sub of chunksChunk) {
|
|
85
85
|
yield* rpcClient.SyncWsRpc.Push({
|
|
86
86
|
storeId,
|
|
@@ -89,7 +89,7 @@ export const makeWsSync = (options) => ({ storeId, payload }) => Effect.gen(func
|
|
|
89
89
|
backendId: backendIdHelper.get(),
|
|
90
90
|
}).pipe(Effect.mapError((cause) => cause._tag === 'InvalidPushError'
|
|
91
91
|
? cause
|
|
92
|
-
: new InvalidPushError({ cause: new
|
|
92
|
+
: new InvalidPushError({ cause: new UnexpectedError({ cause }) })));
|
|
93
93
|
}
|
|
94
94
|
}).pipe(Effect.withSpan('push')),
|
|
95
95
|
ping,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-rpc-client.js","sourceRoot":"","sources":["../../../src/client/transport/ws-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"ws-rpc-client.js","sourceRoot":"","sources":["../../../src/client/transport/ws-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEpH,OAAO,EAAE,g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AAK,EAAE,EAAE,CACxB,KAAK,CAAC,IAAI,KAAK,kBAAkB;oBAC/B,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CACpE,CACF,CAAA;YACH,CAAC;QACH,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI;QACJ,QAAQ,EAAE;YACR,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,kFAAkF;YAC/F,QAAQ,EAAE,IAAI;YACd,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,IAAI;YACvB,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common';
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
3
|
declare const SyncHttpRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncHttpRpc.Pull", Schema.Struct<{
|
|
4
4
|
cursor: Schema.Option<Schema.Struct<{
|
|
@@ -44,7 +44,7 @@ declare const SyncHttpRpc_base: RpcGroup.RpcGroup<Rpc.Rpc<"SyncHttpRpc.Pull", Sc
|
|
|
44
44
|
payload: Schema.optional<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
|
|
45
45
|
}>, Schema.Struct<{
|
|
46
46
|
_tag: Schema.tag<"SyncMessage.Pong">;
|
|
47
|
-
}>, typeof
|
|
47
|
+
}>, typeof UnexpectedError, never>>;
|
|
48
48
|
/**
|
|
49
49
|
* HTTP RPC Schema for LiveStore CF Sync Provider
|
|
50
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"http-rpc-schema.d.ts","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACvF,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG/D;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,gBA4BhC;CAAG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common';
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect';
|
|
3
3
|
import * as SyncMessage from "./sync-message-types.js";
|
|
4
4
|
/**
|
|
@@ -31,7 +31,7 @@ export class SyncHttpRpc extends RpcGroup.make(Rpc.make('SyncHttpRpc.Pull', {
|
|
|
31
31
|
payload: Schema.optional(Schema.JsonValue),
|
|
32
32
|
}),
|
|
33
33
|
success: SyncMessage.Pong,
|
|
34
|
-
error:
|
|
34
|
+
error: UnexpectedError,
|
|
35
35
|
})) {
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=http-rpc-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-rpc-schema.js","sourceRoot":"","sources":["../../src/common/http-rpc-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"http-rpc-schema.js","sourceRoot":"","sources":["../../src/common/http-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C,CACH;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/sync-cf",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-aaba95a52ea7fb67ef08b4bf6fa3d7e36e46ebb8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@cloudflare/workers-types": "4.20250923.0",
|
|
13
|
-
"@livestore/common": "0.0.0-snapshot-
|
|
14
|
-
"@livestore/common-cf": "0.0.0-snapshot-
|
|
15
|
-
"@livestore/utils": "0.0.0-snapshot-
|
|
13
|
+
"@livestore/common": "0.0.0-snapshot-aaba95a52ea7fb67ef08b4bf6fa3d7e36e46ebb8",
|
|
14
|
+
"@livestore/common-cf": "0.0.0-snapshot-aaba95a52ea7fb67ef08b4bf6fa3d7e36e46ebb8",
|
|
15
|
+
"@livestore/utils": "0.0.0-snapshot-aaba95a52ea7fb67ef08b4bf6fa3d7e36e46ebb8"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnexpectedError } from '@livestore/common'
|
|
2
2
|
import { EventSequenceNumber, State } from '@livestore/common/schema'
|
|
3
3
|
import type { CfTypes } from '@livestore/common-cf'
|
|
4
4
|
import { shouldNeverHappen } from '@livestore/utils'
|
|
@@ -43,7 +43,7 @@ export class DoCtx extends Effect.Service<DoCtx>()('DoCtx', {
|
|
|
43
43
|
if (opt?._tag === 'd1') {
|
|
44
44
|
const db = (doSelf.env as any)[opt.binding]
|
|
45
45
|
if (!db) {
|
|
46
|
-
return yield*
|
|
46
|
+
return yield* UnexpectedError.make({ cause: new Error(`D1 binding '${opt.binding}' not found on env`) })
|
|
47
47
|
}
|
|
48
48
|
return { _tag: 'd1' as const, db }
|
|
49
49
|
} else if (opt?._tag === 'do-sqlite' || opt === undefined) {
|
|
@@ -122,7 +122,7 @@ export class DoCtx extends Effect.Service<DoCtx>()('DoCtx', {
|
|
|
122
122
|
|
|
123
123
|
return storageCache
|
|
124
124
|
},
|
|
125
|
-
|
|
125
|
+
UnexpectedError.mapToUnexpectedError,
|
|
126
126
|
Effect.withSpan('@livestore/sync-cf:durable-object:makeDoCtx'),
|
|
127
127
|
),
|
|
128
128
|
}) {}
|
package/src/cf-worker/do/pull.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackendIdMismatchError, InvalidPullError, SyncBackend,
|
|
1
|
+
import { BackendIdMismatchError, InvalidPullError, SyncBackend, UnexpectedError } from '@livestore/common'
|
|
2
2
|
import { splitChunkBySize } from '@livestore/common/sync'
|
|
3
3
|
import { Chunk, Effect, Option, Schema, Stream } from '@livestore/utils/effect'
|
|
4
4
|
import { MAX_PULL_EVENTS_PER_MESSAGE, MAX_WS_MESSAGE_BYTES } from '../../common/constants.ts'
|
|
@@ -24,7 +24,9 @@ export const makeEndingPullStream = (
|
|
|
24
24
|
const { doOptions, backendId, storeId, storage } = yield* DoCtx
|
|
25
25
|
|
|
26
26
|
if (doOptions?.onPull) {
|
|
27
|
-
yield* Effect.tryAll(() => doOptions!.onPull!(req, { storeId, payload })).pipe(
|
|
27
|
+
yield* Effect.tryAll(() => doOptions!.onPull!(req, { storeId, payload })).pipe(
|
|
28
|
+
UnexpectedError.mapToUnexpectedError,
|
|
29
|
+
)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
if (req.cursor._tag === 'Some' && req.cursor.value.backendId !== backendId) {
|
|
@@ -62,7 +64,7 @@ export const makeEndingPullStream = (
|
|
|
62
64
|
Stream.tap(
|
|
63
65
|
Effect.fn(function* (res) {
|
|
64
66
|
if (doOptions?.onPullRes) {
|
|
65
|
-
yield* Effect.tryAll(() => doOptions.onPullRes!(res)).pipe(
|
|
67
|
+
yield* Effect.tryAll(() => doOptions.onPullRes!(res)).pipe(UnexpectedError.mapToUnexpectedError)
|
|
66
68
|
}
|
|
67
69
|
}),
|
|
68
70
|
),
|
package/src/cf-worker/do/push.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
InvalidPushError,
|
|
4
4
|
ServerAheadError,
|
|
5
5
|
SyncBackend,
|
|
6
|
-
|
|
6
|
+
UnexpectedError,
|
|
7
7
|
} from '@livestore/common'
|
|
8
8
|
import { splitChunkBySize } from '@livestore/common/sync'
|
|
9
9
|
import { type CfTypes, emitStreamResponse } from '@livestore/common-cf'
|
|
@@ -41,7 +41,7 @@ export const makePush =
|
|
|
41
41
|
|
|
42
42
|
if (options?.onPush) {
|
|
43
43
|
yield* Effect.tryAll(() => options.onPush!(pushRequest, { storeId, payload })).pipe(
|
|
44
|
-
|
|
44
|
+
UnexpectedError.mapToUnexpectedError,
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -127,7 +127,7 @@ export const makePush =
|
|
|
127
127
|
for (const { response, encoded } of responses) {
|
|
128
128
|
// Only calling once for now.
|
|
129
129
|
if (options?.onPullRes) {
|
|
130
|
-
yield* Effect.tryAll(() => options.onPullRes!(response)).pipe(
|
|
130
|
+
yield* Effect.tryAll(() => options.onPullRes!(response)).pipe(UnexpectedError.mapToUnexpectedError)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// NOTE we're also sending the pullRes chunk to the pushing ws client as confirmation
|
|
@@ -181,7 +181,7 @@ export const makePush =
|
|
|
181
181
|
Effect.tap(
|
|
182
182
|
Effect.fn(function* (message) {
|
|
183
183
|
if (options?.onPushRes) {
|
|
184
|
-
yield* Effect.tryAll(() => options.onPushRes!(message)).pipe(
|
|
184
|
+
yield* Effect.tryAll(() => options.onPushRes!(message)).pipe(UnexpectedError.mapToUnexpectedError)
|
|
185
185
|
}
|
|
186
186
|
}),
|
|
187
187
|
),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnexpectedError } from '@livestore/common'
|
|
2
2
|
import type { LiveStoreEvent } from '@livestore/common/schema'
|
|
3
3
|
import type { CfTypes } from '@livestore/common-cf'
|
|
4
4
|
import { Chunk, Effect, Option, Schema, Stream } from '@livestore/utils/effect'
|
|
@@ -13,16 +13,16 @@ export type SyncStorage = {
|
|
|
13
13
|
total: number
|
|
14
14
|
stream: Stream.Stream<
|
|
15
15
|
{ eventEncoded: LiveStoreEvent.Global.Encoded; metadata: Option.Option<SyncMetadata> },
|
|
16
|
-
|
|
16
|
+
UnexpectedError
|
|
17
17
|
>
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
UnexpectedError
|
|
20
20
|
>
|
|
21
21
|
appendEvents: (
|
|
22
22
|
batch: ReadonlyArray<LiveStoreEvent.Global.Encoded>,
|
|
23
23
|
createdAt: string,
|
|
24
|
-
) => Effect.Effect<void,
|
|
25
|
-
resetStore: Effect.Effect<void,
|
|
24
|
+
) => Effect.Effect<void, UnexpectedError>
|
|
25
|
+
resetStore: Effect.Effect<void, UnexpectedError>
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const makeStorage = (
|
|
@@ -35,7 +35,7 @@ export const makeStorage = (
|
|
|
35
35
|
const execDb = <T>(cb: (db: CfTypes.D1Database) => Promise<CfTypes.D1Result<T>>) =>
|
|
36
36
|
Effect.tryPromise({
|
|
37
37
|
try: () => cb(engine._tag === 'd1' ? engine.db : (undefined as never)),
|
|
38
|
-
catch: (error) => new
|
|
38
|
+
catch: (error) => new UnexpectedError({ cause: error, payload: { dbName } }),
|
|
39
39
|
}).pipe(
|
|
40
40
|
Effect.map((_) => _.results),
|
|
41
41
|
Effect.withSpan('@livestore/sync-cf:durable-object:execDb'),
|
|
@@ -77,10 +77,10 @@ export const makeStorage = (
|
|
|
77
77
|
total: number
|
|
78
78
|
stream: Stream.Stream<
|
|
79
79
|
{ eventEncoded: LiveStoreEvent.Global.Encoded; metadata: Option.Option<SyncMetadata> },
|
|
80
|
-
|
|
80
|
+
UnexpectedError
|
|
81
81
|
>
|
|
82
82
|
},
|
|
83
|
-
|
|
83
|
+
UnexpectedError
|
|
84
84
|
> =>
|
|
85
85
|
Effect.gen(function* () {
|
|
86
86
|
const countStatement =
|
|
@@ -102,7 +102,7 @@ export const makeStorage = (
|
|
|
102
102
|
|
|
103
103
|
const fetchPage = (
|
|
104
104
|
state: State,
|
|
105
|
-
): Effect.Effect<Option.Option<readonly [Chunk.Chunk<EmittedEvent>, State]>,
|
|
105
|
+
): Effect.Effect<Option.Option<readonly [Chunk.Chunk<EmittedEvent>, State]>, UnexpectedError> =>
|
|
106
106
|
Effect.gen(function* () {
|
|
107
107
|
const statement =
|
|
108
108
|
state.cursor === undefined
|
|
@@ -147,7 +147,7 @@ export const makeStorage = (
|
|
|
147
147
|
|
|
148
148
|
return { total, stream }
|
|
149
149
|
}).pipe(
|
|
150
|
-
|
|
150
|
+
UnexpectedError.mapToUnexpectedError,
|
|
151
151
|
Effect.withSpan('@livestore/sync-cf:durable-object:getEvents', {
|
|
152
152
|
attributes: { dbName, cursor, engine: engine._tag },
|
|
153
153
|
}),
|
|
@@ -188,14 +188,14 @@ export const makeStorage = (
|
|
|
188
188
|
)
|
|
189
189
|
}
|
|
190
190
|
}).pipe(
|
|
191
|
-
|
|
191
|
+
UnexpectedError.mapToUnexpectedError,
|
|
192
192
|
Effect.withSpan('@livestore/sync-cf:durable-object:appendEvents', {
|
|
193
193
|
attributes: { dbName, batchLength: batch.length, engine: engine._tag },
|
|
194
194
|
}),
|
|
195
195
|
)
|
|
196
196
|
|
|
197
197
|
const resetStore = Effect.promise(() => ctx.storage.deleteAll()).pipe(
|
|
198
|
-
|
|
198
|
+
UnexpectedError.mapToUnexpectedError,
|
|
199
199
|
Effect.withSpan('@livestore/sync-cf:durable-object:resetStore'),
|
|
200
200
|
)
|
|
201
201
|
|
|
@@ -207,10 +207,10 @@ export const makeStorage = (
|
|
|
207
207
|
total: number
|
|
208
208
|
stream: Stream.Stream<
|
|
209
209
|
{ eventEncoded: LiveStoreEvent.Global.Encoded; metadata: Option.Option<SyncMetadata> },
|
|
210
|
-
|
|
210
|
+
UnexpectedError
|
|
211
211
|
>
|
|
212
212
|
},
|
|
213
|
-
|
|
213
|
+
UnexpectedError
|
|
214
214
|
> =>
|
|
215
215
|
Effect.gen(function* () {
|
|
216
216
|
const selectCountSql =
|
|
@@ -228,7 +228,7 @@ export const makeStorage = (
|
|
|
228
228
|
}
|
|
229
229
|
return computed
|
|
230
230
|
},
|
|
231
|
-
catch: (error) => new
|
|
231
|
+
catch: (error) => new UnexpectedError({ cause: error, payload: { dbName, stage: 'count' } }),
|
|
232
232
|
})
|
|
233
233
|
|
|
234
234
|
type State = { cursor: number | undefined }
|
|
@@ -239,7 +239,7 @@ export const makeStorage = (
|
|
|
239
239
|
|
|
240
240
|
const fetchPage = (
|
|
241
241
|
state: State,
|
|
242
|
-
): Effect.Effect<Option.Option<readonly [Chunk.Chunk<EmittedEvent>, State]>,
|
|
242
|
+
): Effect.Effect<Option.Option<readonly [Chunk.Chunk<EmittedEvent>, State]>, UnexpectedError> =>
|
|
243
243
|
Effect.try({
|
|
244
244
|
try: () => {
|
|
245
245
|
const sql =
|
|
@@ -270,14 +270,14 @@ export const makeStorage = (
|
|
|
270
270
|
|
|
271
271
|
return Option.some([eventsChunk, nextState] as const)
|
|
272
272
|
},
|
|
273
|
-
catch: (error) => new
|
|
273
|
+
catch: (error) => new UnexpectedError({ cause: error, payload: { dbName, stage: 'select' } }),
|
|
274
274
|
})
|
|
275
275
|
|
|
276
276
|
const stream = Stream.unfoldChunkEffect(initialState, fetchPage)
|
|
277
277
|
|
|
278
278
|
return { total, stream }
|
|
279
279
|
}).pipe(
|
|
280
|
-
|
|
280
|
+
UnexpectedError.mapToUnexpectedError,
|
|
281
281
|
Effect.withSpan('@livestore/sync-cf:durable-object:getEvents', {
|
|
282
282
|
attributes: { dbName, cursor, engine: engine._tag },
|
|
283
283
|
}),
|
|
@@ -305,12 +305,12 @@ export const makeStorage = (
|
|
|
305
305
|
ctx.storage.sql.exec(sql, ...params)
|
|
306
306
|
}
|
|
307
307
|
},
|
|
308
|
-
catch: (error) => new
|
|
308
|
+
catch: (error) => new UnexpectedError({ cause: error, payload: { dbName, stage: 'insert' } }),
|
|
309
309
|
}).pipe(
|
|
310
310
|
Effect.withSpan('@livestore/sync-cf:durable-object:appendEvents', {
|
|
311
311
|
attributes: { dbName, batchLength: batch.length, engine: engine._tag },
|
|
312
312
|
}),
|
|
313
|
-
|
|
313
|
+
UnexpectedError.mapToUnexpectedError,
|
|
314
314
|
)
|
|
315
315
|
|
|
316
316
|
if (engine._tag === 'd1') {
|
package/src/cf-worker/worker.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { env as importedEnv } from 'cloudflare:workers'
|
|
2
|
-
import {
|
|
2
|
+
import { UnexpectedError } from '@livestore/common'
|
|
3
3
|
import type { HelperTypes } from '@livestore/common-cf'
|
|
4
4
|
import { Effect, Schema } from '@livestore/utils/effect'
|
|
5
5
|
import type { CfTypes, SearchParams } from '../common/mod.ts'
|
|
@@ -151,7 +151,7 @@ export const makeWorker = <
|
|
|
151
151
|
* }
|
|
152
152
|
* ```
|
|
153
153
|
*
|
|
154
|
-
* @throws {
|
|
154
|
+
* @throws {UnexpectedError} If the payload is invalid
|
|
155
155
|
*/
|
|
156
156
|
export const handleSyncRequest = <
|
|
157
157
|
TEnv extends Env = Env,
|
|
@@ -192,7 +192,7 @@ export const handleSyncRequest = <
|
|
|
192
192
|
|
|
193
193
|
const result = yield* Effect.promise(async () =>
|
|
194
194
|
validatePayload(decodedEither.right as TSyncPayload, { storeId }),
|
|
195
|
-
).pipe(
|
|
195
|
+
).pipe(UnexpectedError.mapToUnexpectedError, Effect.either)
|
|
196
196
|
|
|
197
197
|
if (result._tag === 'Left') {
|
|
198
198
|
console.error('Invalid payload (validation failed)', result.left)
|
|
@@ -200,7 +200,7 @@ export const handleSyncRequest = <
|
|
|
200
200
|
}
|
|
201
201
|
} else {
|
|
202
202
|
const result = yield* Effect.promise(async () => validatePayload(payload as TSyncPayload, { storeId })).pipe(
|
|
203
|
-
|
|
203
|
+
UnexpectedError.mapToUnexpectedError,
|
|
204
204
|
Effect.either,
|
|
205
205
|
)
|
|
206
206
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError, SyncBackend,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, SyncBackend, UnexpectedError } from '@livestore/common'
|
|
2
2
|
import { splitChunkBySize } from '@livestore/common/sync'
|
|
3
3
|
import { type CfTypes, layerProtocolDurableObject } from '@livestore/common-cf'
|
|
4
4
|
import { omit, shouldNeverHappen } from '@livestore/utils'
|
|
@@ -114,7 +114,7 @@ export const makeDoRpcSync =
|
|
|
114
114
|
backendId,
|
|
115
115
|
}),
|
|
116
116
|
}),
|
|
117
|
-
Effect.mapError((cause) => new InvalidPushError({ cause: new
|
|
117
|
+
Effect.mapError((cause) => new InvalidPushError({ cause: new UnexpectedError({ cause }) })),
|
|
118
118
|
)
|
|
119
119
|
|
|
120
120
|
for (const chunk of Chunk.toReadonlyArray(batchChunks)) {
|
|
@@ -123,7 +123,9 @@ export const makeDoRpcSync =
|
|
|
123
123
|
}
|
|
124
124
|
}).pipe(
|
|
125
125
|
Effect.mapError((cause) =>
|
|
126
|
-
cause._tag === 'InvalidPushError'
|
|
126
|
+
cause._tag === 'InvalidPushError'
|
|
127
|
+
? cause
|
|
128
|
+
: InvalidPushError.make({ cause: new UnexpectedError({ cause }) }),
|
|
127
129
|
),
|
|
128
130
|
Effect.withSpan('rpc-sync-client:push'),
|
|
129
131
|
)
|
|
@@ -131,7 +133,7 @@ export const makeDoRpcSync =
|
|
|
131
133
|
const ping: SyncBackend.SyncBackend<{ createdAt: string }>['ping'] = rpcClient.SyncDoRpc.Ping({
|
|
132
134
|
storeId,
|
|
133
135
|
payload,
|
|
134
|
-
}).pipe(
|
|
136
|
+
}).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('rpc-sync-client:ping'))
|
|
135
137
|
|
|
136
138
|
return SyncBackend.of({
|
|
137
139
|
connect,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError, SyncBackend,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, SyncBackend, UnexpectedError } from '@livestore/common'
|
|
2
2
|
import type { EventSequenceNumber } from '@livestore/common/schema'
|
|
3
3
|
import { splitChunkBySize } from '@livestore/common/sync'
|
|
4
4
|
import { omit } from '@livestore/utils'
|
|
@@ -76,7 +76,7 @@ export const makeHttpSync =
|
|
|
76
76
|
storeId,
|
|
77
77
|
payload,
|
|
78
78
|
transport: 'http',
|
|
79
|
-
}).pipe(
|
|
79
|
+
}).pipe(UnexpectedError.mapToUnexpectedError)
|
|
80
80
|
|
|
81
81
|
const urlParams = UrlParams.fromInput(urlParamsData)
|
|
82
82
|
|
|
@@ -103,7 +103,7 @@ export const makeHttpSync =
|
|
|
103
103
|
|
|
104
104
|
yield* SubscriptionRef.set(isConnected, true)
|
|
105
105
|
}).pipe(
|
|
106
|
-
|
|
106
|
+
UnexpectedError.mapToUnexpectedError,
|
|
107
107
|
Effect.timeout(pingTimeout),
|
|
108
108
|
Effect.catchTag('TimeoutException', () => SubscriptionRef.set(isConnected, false)),
|
|
109
109
|
)
|
|
@@ -116,7 +116,7 @@ export const makeHttpSync =
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// Helps already establish a TCP connection to the server
|
|
119
|
-
const connect = ping.pipe(
|
|
119
|
+
const connect = ping.pipe(UnexpectedError.mapToUnexpectedError)
|
|
120
120
|
|
|
121
121
|
const backendIdHelper = yield* SyncBackend.makeBackendIdHelper
|
|
122
122
|
|
|
@@ -190,7 +190,7 @@ export const makeHttpSync =
|
|
|
190
190
|
backendId,
|
|
191
191
|
}),
|
|
192
192
|
}),
|
|
193
|
-
Effect.mapError((cause) => new InvalidPushError({ cause: new
|
|
193
|
+
Effect.mapError((cause) => new InvalidPushError({ cause: new UnexpectedError({ cause }) })),
|
|
194
194
|
)
|
|
195
195
|
|
|
196
196
|
for (const chunk of Chunk.toReadonlyArray(batchChunks)) {
|
|
@@ -200,7 +200,7 @@ export const makeHttpSync =
|
|
|
200
200
|
}).pipe(
|
|
201
201
|
pushSemaphore.withPermits(1),
|
|
202
202
|
Effect.mapError((cause) =>
|
|
203
|
-
cause._tag === 'InvalidPushError' ? cause : new InvalidPushError({ cause: new
|
|
203
|
+
cause._tag === 'InvalidPushError' ? cause : new InvalidPushError({ cause: new UnexpectedError({ cause }) }),
|
|
204
204
|
),
|
|
205
205
|
Effect.withSpan('http-sync-client:push'),
|
|
206
206
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError, IsOfflineError, SyncBackend,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, IsOfflineError, SyncBackend, UnexpectedError } from '@livestore/common'
|
|
2
2
|
import type { LiveStoreEvent } from '@livestore/common/schema'
|
|
3
3
|
import { splitChunkBySize } from '@livestore/common/sync'
|
|
4
4
|
import { omit } from '@livestore/utils'
|
|
@@ -73,7 +73,7 @@ export const makeWsSync =
|
|
|
73
73
|
storeId,
|
|
74
74
|
payload,
|
|
75
75
|
transport: 'ws',
|
|
76
|
-
}).pipe(
|
|
76
|
+
}).pipe(UnexpectedError.mapToUnexpectedError)
|
|
77
77
|
|
|
78
78
|
const urlParams = UrlParams.fromInput(urlParamsData)
|
|
79
79
|
const wsUrl = `${options.url}?${UrlParams.toString(urlParams)}`
|
|
@@ -119,7 +119,7 @@ export const makeWsSync =
|
|
|
119
119
|
}).pipe(
|
|
120
120
|
Effect.timeout(pingTimeout),
|
|
121
121
|
Effect.catchTag('TimeoutException', () => SubscriptionRef.set(isConnected, false)),
|
|
122
|
-
|
|
122
|
+
UnexpectedError.mapToUnexpectedError,
|
|
123
123
|
Effect.withSpan('ping'),
|
|
124
124
|
)
|
|
125
125
|
|
|
@@ -169,7 +169,7 @@ export const makeWsSync =
|
|
|
169
169
|
maxBytes: MAX_WS_MESSAGE_BYTES,
|
|
170
170
|
encode: encodePayload,
|
|
171
171
|
}),
|
|
172
|
-
Effect.mapError((cause) => new InvalidPushError({ cause: new
|
|
172
|
+
Effect.mapError((cause) => new InvalidPushError({ cause: new UnexpectedError({ cause }) })),
|
|
173
173
|
)
|
|
174
174
|
|
|
175
175
|
for (const sub of chunksChunk) {
|
|
@@ -182,7 +182,7 @@ export const makeWsSync =
|
|
|
182
182
|
Effect.mapError((cause) =>
|
|
183
183
|
cause._tag === 'InvalidPushError'
|
|
184
184
|
? cause
|
|
185
|
-
: new InvalidPushError({ cause: new
|
|
185
|
+
: new InvalidPushError({ cause: new UnexpectedError({ cause }) }),
|
|
186
186
|
),
|
|
187
187
|
)
|
|
188
188
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidPullError, InvalidPushError,
|
|
1
|
+
import { InvalidPullError, InvalidPushError, UnexpectedError } from '@livestore/common'
|
|
2
2
|
import { Rpc, RpcGroup, Schema } from '@livestore/utils/effect'
|
|
3
3
|
import * as SyncMessage from './sync-message-types.ts'
|
|
4
4
|
|
|
@@ -35,6 +35,6 @@ export class SyncHttpRpc extends RpcGroup.make(
|
|
|
35
35
|
payload: Schema.optional(Schema.JsonValue),
|
|
36
36
|
}),
|
|
37
37
|
success: SyncMessage.Pong,
|
|
38
|
-
error:
|
|
38
|
+
error: UnexpectedError,
|
|
39
39
|
}),
|
|
40
40
|
) {}
|