orez-sync-cf-host 0.5.6 → 0.5.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orez-sync-cf-host",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
Binary file
package/src/host.ts CHANGED
@@ -715,7 +715,11 @@ export function createSyncDurableObject<Env extends SyncHostEnv>(
715
715
  })
716
716
  }
717
717
  if (result.caughtUp) break
718
- if (result.applied === 0) {
718
+ // a page can legitimately apply zero rows while still advancing the
719
+ // watermark: the engine consumes changes for tables this host does not
720
+ // model (subset replica) without materializing them. only a page that
721
+ // neither applied nor advanced is genuinely stalled.
722
+ if (result.applied === 0 && String(nextCursor) === String(cursor)) {
719
723
  this.#tripIngest('ingestCursorStalled', {
720
724
  phase: 'changes',
721
725
  cursor,
@@ -893,6 +897,14 @@ export function createSyncDurableObject<Env extends SyncHostEnv>(
893
897
  (typeof config.queryAware === 'function'
894
898
  ? config.queryAware(claims)
895
899
  : (config.queryAware ?? Boolean(config.resolveQuery)))
900
+ const transformVersion = queryAware
901
+ ? typeof config.queryTransformVersion === 'function'
902
+ ? config.queryTransformVersion(claims)
903
+ : (config.queryTransformVersion ?? 0)
904
+ : 0
905
+ if (!Number.isSafeInteger(transformVersion) || transformVersion < 0) {
906
+ throw new TypeError('queryTransformVersion must be a non-negative safe integer')
907
+ }
896
908
  if (queryAware && body.queries) {
897
909
  const queries = body.queries as {
898
910
  version?: unknown
@@ -925,15 +937,6 @@ export function createSyncDurableObject<Env extends SyncHostEnv>(
925
937
  } catch (error) {
926
938
  throw requestError(`unknown or unsupported named query: ${op.name}`)
927
939
  }
928
- const transformVersion =
929
- typeof config.queryTransformVersion === 'function'
930
- ? config.queryTransformVersion(claims)
931
- : (config.queryTransformVersion ?? 0)
932
- if (!Number.isSafeInteger(transformVersion) || transformVersion < 0) {
933
- throw new TypeError(
934
- 'queryTransformVersion must be a non-negative safe integer'
935
- )
936
- }
937
940
  patch.push({
938
941
  op: 'put',
939
942
  hash: op.hash,
@@ -945,6 +948,9 @@ export function createSyncDurableObject<Env extends SyncHostEnv>(
945
948
  body = { ...body, queries: { ...queries, patch } }
946
949
  }
947
950
  }
951
+ if (queryAware) {
952
+ body = { ...body, _serverQueryTransformVersion: transformVersion }
953
+ }
948
954
  const clientID = typeof body.clientID === 'string' ? body.clientID : ''
949
955
  this.#pulling.add(clientID)
950
956
  let response: Record<string, unknown>