@powersync/common 0.0.0-dev-20260414110516 → 0.0.0-dev-20260503073249

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.
@@ -1977,16 +1977,12 @@ class SyncStatus {
1977
1977
  *
1978
1978
  * This returns null when the database is currently being opened and we don't have reliable information about all
1979
1979
  * included streams yet.
1980
- *
1981
- * @experimental Sync streams are currently in alpha.
1982
1980
  */
1983
1981
  get syncStreams() {
1984
1982
  return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
1985
1983
  }
1986
1984
  /**
1987
1985
  * If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
1988
- *
1989
- * @experimental Sync streams are currently in alpha.
1990
1986
  */
1991
1987
  forStream(stream) {
1992
1988
  const asJson = JSON.stringify(stream.parameters);
@@ -8220,7 +8216,7 @@ function requireDist () {
8220
8216
 
8221
8217
  var distExports = requireDist();
8222
8218
 
8223
- var version = "1.51.0";
8219
+ var version = "1.52.0";
8224
8220
  var PACKAGE = {
8225
8221
  version: version};
8226
8222
 
@@ -9199,6 +9195,7 @@ class AbstractStreamingSyncImplementation extends BaseObserver {
9199
9195
  streamingSyncPromise;
9200
9196
  logger;
9201
9197
  activeStreams;
9198
+ connectionMayHaveChanged = false;
9202
9199
  isUploadingCrud = false;
9203
9200
  notifyCompletedUploads;
9204
9201
  handleActiveStreamsChange;
@@ -9478,6 +9475,11 @@ The next upload iteration will be delayed.`);
9478
9475
  shouldDelayRetry = false;
9479
9476
  // A disconnect was requested, we should not delay since there is no explicit retry
9480
9477
  }
9478
+ else if (this.connectionMayHaveChanged && ex.message?.indexOf('No iteration is active') >= 0) {
9479
+ this.connectionMayHaveChanged = false;
9480
+ this.logger.info('Sync error after changed connection, retrying immediately');
9481
+ shouldDelayRetry = false;
9482
+ }
9481
9483
  else {
9482
9484
  this.logger.error(ex);
9483
9485
  }
@@ -9508,6 +9510,15 @@ The next upload iteration will be delayed.`);
9508
9510
  // Mark as disconnected if here
9509
9511
  this.updateSyncStatus({ connected: false, connecting: false });
9510
9512
  }
9513
+ markConnectionMayHaveChanged() {
9514
+ // By setting this field, we'll immediately retry if the next sync event causes an error triggered by us not having
9515
+ // an active sync iteration on the connection in use.
9516
+ this.connectionMayHaveChanged = true;
9517
+ // This triggers a `powersync_control` invocation if a sync iteration is currently active. This is a cheap call to
9518
+ // make when no subscriptions have actually changed, we're mainly interested in this immediately throwing if no
9519
+ // iteration is active. That allows us to reconnect ASAP, instead of having to wait for the next sync line.
9520
+ this.handleActiveStreamsChange?.();
9521
+ }
9511
9522
  async collectLocalBucketState() {
9512
9523
  const bucketEntries = await this.options.adapter.getBucketStates();
9513
9524
  const req = bucketEntries.map((entry) => ({
@@ -9880,6 +9891,10 @@ The next upload iteration will be delayed.`);
9880
9891
  const rawResponse = await adapter.control(op, payload ?? null);
9881
9892
  const logger = syncImplementation.logger;
9882
9893
  logger.trace('powersync_control', op, payload == null || typeof payload == 'string' ? payload : '<bytes>', rawResponse);
9894
+ if (op != PowerSyncControlCommand.STOP) {
9895
+ // Evidently we have a working connection here, otherwise powersync_control would have failed.
9896
+ syncImplementation.connectionMayHaveChanged = false;
9897
+ }
9883
9898
  await handleInstructions(JSON.parse(rawResponse));
9884
9899
  }
9885
9900
  async function handleInstruction(instruction) {
@@ -11949,10 +11964,8 @@ class Schema {
11949
11964
  * developer instead of automatically by PowerSync.
11950
11965
  * Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
11951
11966
  * using client-side table and column constraints.
11952
- * Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
11953
11967
  *
11954
11968
  * @param tables An object of (table name, raw table definition) entries.
11955
- * @experimental Note that the raw tables API is still experimental and may change in the future.
11956
11969
  */
11957
11970
  withRawTables(tables) {
11958
11971
  for (const [name, rawTableDefinition] of Object.entries(tables)) {