@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.
package/dist/bundle.mjs CHANGED
@@ -2135,11 +2135,7 @@ class SyncStatus {
2135
2135
  */
2136
2136
  const replacer = (_, value) => {
2137
2137
  if (value instanceof Error) {
2138
- return {
2139
- name: value.name,
2140
- message: value.message,
2141
- stack: value.stack
2142
- };
2138
+ return this.serializeError(value);
2143
2139
  }
2144
2140
  return value;
2145
2141
  };
@@ -2182,11 +2178,18 @@ class SyncStatus {
2182
2178
  if (typeof error == 'undefined') {
2183
2179
  return undefined;
2184
2180
  }
2185
- return {
2181
+ const serialized = {
2186
2182
  name: error.name,
2187
2183
  message: error.message,
2188
2184
  stack: error.stack
2189
2185
  };
2186
+ // `Error.cause` can be any value (the spec types it as unknown). Preserve it
2187
+ // so consumers reading uploadError/downloadError keep the failure context.
2188
+ // Recurse for Error causes so the whole chain is flattened the same way.
2189
+ if (typeof error.cause != 'undefined') {
2190
+ serialized.cause = error.cause instanceof Error ? this.serializeError(error.cause) : error.cause;
2191
+ }
2192
+ return serialized;
2190
2193
  }
2191
2194
  static comparePriorities(a, b) {
2192
2195
  return b.priority - a.priority; // Reverse because higher priorities have lower numbers
@@ -10911,7 +10914,7 @@ function requireDist () {
10911
10914
 
10912
10915
  var distExports = requireDist();
10913
10916
 
10914
- var version = "1.55.0";
10917
+ var version = "1.56.0";
10915
10918
  var PACKAGE = {
10916
10919
  version: version};
10917
10920
 
@@ -13042,7 +13045,7 @@ class AbstractPowerSyncDatabase extends BaseObserver {
13042
13045
  this.logger.warn('Schema validation failed. Unexpected behaviour could occur', ex);
13043
13046
  }
13044
13047
  this._schema = schema;
13045
- await this.database.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]);
13048
+ await this.database.writeTransaction((tx) => tx.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]));
13046
13049
  await this.database.refreshSchema();
13047
13050
  this.iterateListeners(async (cb) => cb.schemaChanged?.(schema));
13048
13051
  }