[GH-ISSUE #258] DataReference.transaction returning null, even through .get immediately before returns value. #117

Closed
opened 2026-05-23 08:31:11 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @xenobytezero on GitHub (Feb 4, 2025).
Original GitHub issue: https://github.com/appy-one/acebase/issues/258

I'm working on creating a repro repo, but I just want to check I'm not doing anything incredibly dumb.

I have a acebase-server instance that I'm connecting to from my page, and I'm having a problem with the following code.


  // get the ref for the logged in user
  const userRef = this._userDB.child<UserDBStruct>(userId);

  // get just the user info
  const userInfoRef = userRef.child('info');

  // if the user doesn't exist, we are done
  if (!(await userInfoRef.exists())) {
      this.clearLoginData();
      return false;
  }

  const info = (await userInfoRef.get()).val();

  console.log(info);

  // mark ourselves as loggedIn in the database
  await userInfoRef.transaction<UserInfo>((snapshot) => {
      const curr = snapshot.val();

      if (curr === null) {
          throw new Error('No UserInfo for user');
      }

When running the above

  • the userInfoRef.exists() call returns true
  • the `userInfoRef.get().val() returns the correct data from the database
  • the snapshot inside the transaction returns null every time

Is there something really obvious I'm doing wrong here?

Originally created by @xenobytezero on GitHub (Feb 4, 2025). Original GitHub issue: https://github.com/appy-one/acebase/issues/258 I'm working on creating a repro repo, but I just want to check I'm not doing anything incredibly dumb. I have a `acebase-server` instance that I'm connecting to from my page, and I'm having a problem with the following code. ```ts // get the ref for the logged in user const userRef = this._userDB.child<UserDBStruct>(userId); // get just the user info const userInfoRef = userRef.child('info'); // if the user doesn't exist, we are done if (!(await userInfoRef.exists())) { this.clearLoginData(); return false; } const info = (await userInfoRef.get()).val(); console.log(info); // mark ourselves as loggedIn in the database await userInfoRef.transaction<UserInfo>((snapshot) => { const curr = snapshot.val(); if (curr === null) { throw new Error('No UserInfo for user'); } ``` When running the above - the `userInfoRef.exists()` call returns true - the `userInfoRef.get().val() returns the correct data from the database - the `snapshot` inside the transaction returns null every time Is there something really obvious I'm doing wrong here?
Author
Owner

@xenobytezero commented on GitHub (Feb 4, 2025):

Realised after hours of debugging my issue was around my attempts to use a reverse proxy to front multiple Acebase instances, which was failing in an incredibly subtle way.

Happy to close/delete this!

<!-- gh-comment-id:2635306035 --> @xenobytezero commented on GitHub (Feb 4, 2025): Realised after hours of debugging my issue was around my attempts to use a reverse proxy to front multiple Acebase instances, which was failing in an incredibly subtle way. Happy to close/delete this!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#117
No description provided.