@powersync/common 1.55.0 → 1.56.0

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.
@@ -2139,11 +2139,7 @@ class SyncStatus {
2139
2139
  */
2140
2140
  const replacer = (_, value) => {
2141
2141
  if (value instanceof Error) {
2142
- return {
2143
- name: value.name,
2144
- message: value.message,
2145
- stack: value.stack
2146
- };
2142
+ return this.serializeError(value);
2147
2143
  }
2148
2144
  return value;
2149
2145
  };
@@ -2186,11 +2182,18 @@ class SyncStatus {
2186
2182
  if (typeof error == 'undefined') {
2187
2183
  return undefined;
2188
2184
  }
2189
- return {
2185
+ const serialized = {
2190
2186
  name: error.name,
2191
2187
  message: error.message,
2192
2188
  stack: error.stack
2193
2189
  };
2190
+ // `Error.cause` can be any value (the spec types it as unknown). Preserve it
2191
+ // so consumers reading uploadError/downloadError keep the failure context.
2192
+ // Recurse for Error causes so the whole chain is flattened the same way.
2193
+ if (typeof error.cause != 'undefined') {
2194
+ serialized.cause = error.cause instanceof Error ? this.serializeError(error.cause) : error.cause;
2195
+ }
2196
+ return serialized;
2194
2197
  }
2195
2198
  static comparePriorities(a, b) {
2196
2199
  return b.priority - a.priority; // Reverse because higher priorities have lower numbers
@@ -8544,7 +8547,7 @@ function requireDist () {
8544
8547
 
8545
8548
  var distExports = requireDist();
8546
8549
 
8547
- var version = "1.55.0";
8550
+ var version = "1.56.0";
8548
8551
  var PACKAGE = {
8549
8552
  version: version};
8550
8553
 
@@ -10675,7 +10678,7 @@ class AbstractPowerSyncDatabase extends BaseObserver {
10675
10678
  this.logger.warn('Schema validation failed. Unexpected behaviour could occur', ex);
10676
10679
  }
10677
10680
  this._schema = schema;
10678
- await this.database.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]);
10681
+ await this.database.writeTransaction((tx) => tx.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]));
10679
10682
  await this.database.refreshSchema();
10680
10683
  this.iterateListeners(async (cb) => cb.schemaChanged?.(schema));
10681
10684
  }