@instantdb/core 0.22.123 → 0.22.124

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/core",
3
- "version": "0.22.123",
3
+ "version": "0.22.124",
4
4
  "description": "Instant's core local abstraction",
5
5
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "dependencies": {
54
54
  "mutative": "^1.0.10",
55
55
  "uuid": "^11.1.0",
56
- "@instantdb/version": "0.22.123"
56
+ "@instantdb/version": "0.22.124"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest",
package/src/Reactor.js CHANGED
@@ -318,7 +318,9 @@ export default class Reactor {
318
318
  try {
319
319
  if (e.data?.type === 'auth') {
320
320
  const res = await this.getCurrentUser();
321
- this.updateUser(res.user);
321
+ await this.updateUser(res.user).catch((error) => {
322
+ this._log.error('[error] update user', error);
323
+ });
322
324
  }
323
325
  } catch (e) {
324
326
  this._log.error('[error] handle broadcast channel', e);
@@ -2044,7 +2046,7 @@ export default class Reactor {
2044
2046
  await this.setCurrentUser(newUser);
2045
2047
  // We need to remove all `result` from querySubs,
2046
2048
  // as they are no longer valid for the new user
2047
- this.updateUser(newUser);
2049
+ await this.updateUser(newUser);
2048
2050
 
2049
2051
  try {
2050
2052
  this._broadcastChannel?.postMessage({ type: 'auth' });
@@ -2056,7 +2058,7 @@ export default class Reactor {
2056
2058
  async syncUserToEndpoint(user) {
2057
2059
  if (!this.config.firstPartyPath) return;
2058
2060
  try {
2059
- fetch(this.config.firstPartyPath + '/', {
2061
+ await fetch(this.config.firstPartyPath + '/', {
2060
2062
  method: 'POST',
2061
2063
  body: JSON.stringify({
2062
2064
  type: 'sync-user',
@@ -2072,8 +2074,12 @@ export default class Reactor {
2072
2074
  }
2073
2075
  }
2074
2076
 
2075
- updateUser(newUser) {
2076
- this.syncUserToEndpoint(newUser);
2077
+ async updateUser(newUser) {
2078
+ try {
2079
+ await this.syncUserToEndpoint(newUser);
2080
+ } catch (error) {
2081
+ this._log.error('Error syncing user with external endpoint', error);
2082
+ }
2077
2083
 
2078
2084
  const newV = { error: undefined, user: newUser };
2079
2085
  this._currentUserCached = { isLoading: false, ...newV };