Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runTransaction errors are not catchable #7919

Open
marcusx2 opened this issue Jan 3, 2024 · 0 comments
Open

runTransaction errors are not catchable #7919

marcusx2 opened this issue Jan 3, 2024 · 0 comments

Comments

@marcusx2
Copy link

marcusx2 commented Jan 3, 2024

Operating System

macOS

Browser Version

Safari 16.5.2

Firebase SDK Version

10.7.1

Firebase SDK Product:

Database

Describe your project's tooling

index.html with source tag. Just javascript.

Describe the problem

runTransaction errors can not be caught.

Steps and code to reproduce issue

Start with the database empty.

var db = getDatabase();
connectDatabaseEmulator(db, '127.0.0.1', 9000);
await update(ref(db, "users/testUser/starCount"), { starCount: increment(1) });
try {
    await runTransaction(ref(db, "users/testUser"), post => {
        console.log(post);
        if (post) {
            var starCount = post["starCount"];
            starCount++;
            post["starCount"] = starCount;
            return post;
        } else {
           return null;
        }
    });
} catch (e) {//it never reaches catch
    console.error("transaction error");
    console.error(e);
}

The following error shows up on the console

Error: transaction failed: Data returned contains NaN in property 'users.testUser.starCount'

However, the error can never be caught. I also tried using a try catch block inside the transaction itself, and it still didn't work.

@marcusx2 marcusx2 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jan 3, 2024
@jbalidiong jbalidiong added needs-attention testing-sdk testing with emulator and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants