@powersync/web 1.38.4 → 1.38.5

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.
@@ -3870,11 +3870,7 @@ class SyncStatus {
3870
3870
  */
3871
3871
  const replacer = (_, value) => {
3872
3872
  if (value instanceof Error) {
3873
- return {
3874
- name: value.name,
3875
- message: value.message,
3876
- stack: value.stack
3877
- };
3873
+ return this.serializeError(value);
3878
3874
  }
3879
3875
  return value;
3880
3876
  };
@@ -3917,11 +3913,18 @@ class SyncStatus {
3917
3913
  if (typeof error == 'undefined') {
3918
3914
  return undefined;
3919
3915
  }
3920
- return {
3916
+ const serialized = {
3921
3917
  name: error.name,
3922
3918
  message: error.message,
3923
3919
  stack: error.stack
3924
3920
  };
3921
+ // `Error.cause` can be any value (the spec types it as unknown). Preserve it
3922
+ // so consumers reading uploadError/downloadError keep the failure context.
3923
+ // Recurse for Error causes so the whole chain is flattened the same way.
3924
+ if (typeof error.cause != 'undefined') {
3925
+ serialized.cause = error.cause instanceof Error ? this.serializeError(error.cause) : error.cause;
3926
+ }
3927
+ return serialized;
3925
3928
  }
3926
3929
  static comparePriorities(a, b) {
3927
3930
  return b.priority - a.priority; // Reverse because higher priorities have lower numbers
@@ -12646,7 +12649,7 @@ function requireDist () {
12646
12649
 
12647
12650
  var distExports = requireDist();
12648
12651
 
12649
- var version = "1.55.0";
12652
+ var version = "1.56.0";
12650
12653
  var PACKAGE = {
12651
12654
  version: version};
12652
12655
 
@@ -14777,7 +14780,7 @@ class AbstractPowerSyncDatabase extends BaseObserver {
14777
14780
  this.logger.warn('Schema validation failed. Unexpected behaviour could occur', ex);
14778
14781
  }
14779
14782
  this._schema = schema;
14780
- await this.database.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]);
14783
+ await this.database.writeTransaction((tx) => tx.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]));
14781
14784
  await this.database.refreshSchema();
14782
14785
  this.iterateListeners(async (cb) => cb.schemaChanged?.(schema));
14783
14786
  }