@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.
package/dist/bundle.mjs CHANGED
@@ -2129,16 +2129,12 @@ class SyncStatus {
2129
2129
  *
2130
2130
  * This returns null when the database is currently being opened and we don't have reliable information about all
2131
2131
  * included streams yet.
2132
- *
2133
- * @experimental Sync streams are currently in alpha.
2134
2132
  */
2135
2133
  get syncStreams() {
2136
2134
  return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
2137
2135
  }
2138
2136
  /**
2139
2137
  * If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
2140
- *
2141
- * @experimental Sync streams are currently in alpha.
2142
2138
  */
2143
2139
  forStream(stream) {
2144
2140
  const asJson = JSON.stringify(stream.parameters);
@@ -10743,7 +10739,7 @@ function requireDist () {
10743
10739
 
10744
10740
  var distExports = requireDist();
10745
10741
 
10746
- var version = "1.51.0";
10742
+ var version = "1.52.0";
10747
10743
  var PACKAGE = {
10748
10744
  version: version};
10749
10745
 
@@ -11722,6 +11718,7 @@ class AbstractStreamingSyncImplementation extends BaseObserver {
11722
11718
  streamingSyncPromise;
11723
11719
  logger;
11724
11720
  activeStreams;
11721
+ connectionMayHaveChanged = false;
11725
11722
  isUploadingCrud = false;
11726
11723
  notifyCompletedUploads;
11727
11724
  handleActiveStreamsChange;
@@ -12001,6 +11998,11 @@ The next upload iteration will be delayed.`);
12001
11998
  shouldDelayRetry = false;
12002
11999
  // A disconnect was requested, we should not delay since there is no explicit retry
12003
12000
  }
12001
+ else if (this.connectionMayHaveChanged && ex.message?.indexOf('No iteration is active') >= 0) {
12002
+ this.connectionMayHaveChanged = false;
12003
+ this.logger.info('Sync error after changed connection, retrying immediately');
12004
+ shouldDelayRetry = false;
12005
+ }
12004
12006
  else {
12005
12007
  this.logger.error(ex);
12006
12008
  }
@@ -12031,6 +12033,15 @@ The next upload iteration will be delayed.`);
12031
12033
  // Mark as disconnected if here
12032
12034
  this.updateSyncStatus({ connected: false, connecting: false });
12033
12035
  }
12036
+ markConnectionMayHaveChanged() {
12037
+ // By setting this field, we'll immediately retry if the next sync event causes an error triggered by us not having
12038
+ // an active sync iteration on the connection in use.
12039
+ this.connectionMayHaveChanged = true;
12040
+ // This triggers a `powersync_control` invocation if a sync iteration is currently active. This is a cheap call to
12041
+ // make when no subscriptions have actually changed, we're mainly interested in this immediately throwing if no
12042
+ // iteration is active. That allows us to reconnect ASAP, instead of having to wait for the next sync line.
12043
+ this.handleActiveStreamsChange?.();
12044
+ }
12034
12045
  async collectLocalBucketState() {
12035
12046
  const bucketEntries = await this.options.adapter.getBucketStates();
12036
12047
  const req = bucketEntries.map((entry) => ({
@@ -12403,6 +12414,10 @@ The next upload iteration will be delayed.`);
12403
12414
  const rawResponse = await adapter.control(op, payload ?? null);
12404
12415
  const logger = syncImplementation.logger;
12405
12416
  logger.trace('powersync_control', op, payload == null || typeof payload == 'string' ? payload : '<bytes>', rawResponse);
12417
+ if (op != PowerSyncControlCommand.STOP) {
12418
+ // Evidently we have a working connection here, otherwise powersync_control would have failed.
12419
+ syncImplementation.connectionMayHaveChanged = false;
12420
+ }
12406
12421
  await handleInstructions(JSON.parse(rawResponse));
12407
12422
  }
12408
12423
  async function handleInstruction(instruction) {
@@ -14472,10 +14487,8 @@ class Schema {
14472
14487
  * developer instead of automatically by PowerSync.
14473
14488
  * Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
14474
14489
  * using client-side table and column constraints.
14475
- * Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
14476
14490
  *
14477
14491
  * @param tables An object of (table name, raw table definition) entries.
14478
- * @experimental Note that the raw tables API is still experimental and may change in the future.
14479
14492
  */
14480
14493
  withRawTables(tables) {
14481
14494
  for (const [name, rawTableDefinition] of Object.entries(tables)) {