firebase / firebase/firebase-admin-node

Realtime Database - indefinite hold after calling get()

Open
#2,638 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api: database
Dominant language
TypeScript
Stars
1.7k
Forks
419
Avg merge
3d 10h
Merged PRs (30d)
16

Description

Operating System

Node JS 16

Browser Version

Admin SDK

Firebase SDK Version

11.7.0 (and also 12.2.0)

Firebase SDK Product:

Database

Describe your project's tooling

Admin Node JS SDK

Describe the problem

Hi guys,

I built a simple script in Typescript that reads from the Database and prints the result. Whenever I do that, the newly created process does not close.

I'm not sure if this is an intended behaviour

I also added the admin.database().goOffline(); as mentioned in https://github.com/firebase/firebase-js-sdk/issues/6932#issuecomment-1385331994 but didn't work.

Steps and code to reproduce issue

Run the following js code

admin.initializeApp();
_test();
async function _test() {
    const ref = await admin
        .database()
        .ref('YOUR_REFERENCE')
        .get();
    const start_data = ref.val();
    console.log(start_data);
    admin.database().goOffline();
    console.log('end');
}

You'll see that even though the console prints 'end', the program doesn't actually stop.

If you simply run

admin.initializeApp();
_test();
async function _test() {
  console.log('end');
}

the program stops as intended

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied Admin Node.js script using admin.initializeApp(), database().ref().get(), and goOffline(), then inspect the Realtime Database path used by the Admin SDK. Done means the process exits after the read and the final log without requiring an additional workaround; the payload names no repository files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.