firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

console.log "heartbeats" is unnecessary

Open tzappia opened this issue 1 year ago • 18 comments
trafficstars

Operating System

macOS 14.6.1

Browser Version

Chrome/127.0.6533.120

Firebase SDK Version

10.13.0

Firebase SDK Product:

Auth, Firestore, Functions, Storage

Describe your project's tooling

Angular v18 app

Describe the problem

During initialization, an unhelpful console.log is repeated:

heartbeats undefined

Steps and code to reproduce issue

After initializing the app, initialize Firestore (for example)

    this.app = initializeApp({
      apiKey: environment.firebase.apiKey,
      authDomain: environment.firebase.authDomain,
      databaseURL: environment.firebase.databaseURL,
      projectId: environment.firebase.projectId,
      storageBucket: environment.firebase.storageBucket,
      messagingSenderId: environment.firebase.messagingSenderId,
      appId: environment.firebase.appId,
    });

    this.db = initializeFirestore(this.app, {
      ignoreUndefinedProperties: true,
    });

tzappia avatar Aug 17 '24 14:08 tzappia

Appears to have been introduced with #8425

tzappia avatar Aug 17 '24 14:08 tzappia

Can confirm that after updating to "firebase": "^10.13.0", i now end up getting:

image

bastianbrouwers avatar Aug 18 '24 16:08 bastianbrouwers

Same, but in a react app and it's super noisy in the logs and in local dev.

heartbeats [
  {
    date: '2024-08-18',
    agent: 'fire-core/0.10.9 fire-core-esm2017/0.10.9 fire-js/ fire-js-all-app/10.13.0 fire-gcs/0.13.0 fire-fn-node/0.11.6 fire-fn-esm2017/0.11.6 fire-auth-node/1.7.7 fire-auth-esm2017/1.7.7 fire-rtdb-node/1.0.7 fire-rtdb-esm2017/1.0.7 fire-fst-node/4.7.0 fire-fst-esm2017/4.7.0 fire-iid/0.6.8 fire-iid-esm2017/0.6.8 fire-analytics/0.10.7 fire-analytics-esm2017/0.10.7'
  }
]

NickFoden avatar Aug 18 '24 20:08 NickFoden

Same problem.

hqw567 avatar Aug 19 '24 06:08 hqw567

Hi @tzappia, thank for bringing this to our attention. I was able to reproduce the behavior. Let me check what we can do for this issue or bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.

jbalidiong avatar Aug 19 '24 08:08 jbalidiong

Experiencing the same issue when I just updgraded to "firebase": "^10.13.0".

jeffgaynor avatar Aug 19 '24 13:08 jeffgaynor

Thanks for reporting this!

This was introduced in 10.13.0, so if anyone wants to get rid of this they can downgrade to 10.12.5 until the removal of the console.log is released next Thursday.

dlarocque avatar Aug 19 '24 14:08 dlarocque

This was introduced in 10.13.0, so if anyone wants to get rid of this they can downgrade to 10.12.5 until the removal of the console.log is released next Thursday.

~~10.12.5~~ 10.12.4

ben519 avatar Aug 19 '24 19:08 ben519

This was introduced in 10.13.0, so if anyone wants to get rid of this they can downgrade to 10.12.5 until the removal of the console.log is released next Thursday.

~10.12.5~ 10.12.4

Are you seeing this in 10.12.4? The PR was merged into the 10.13 release here https://github.com/firebase/firebase-js-sdk/pull/8426

dlarocque avatar Aug 19 '24 19:08 dlarocque

Are you seeing this in 10.12.4?

No, but I see it in 10.12.5

ben519 avatar Aug 19 '24 19:08 ben519

Are you seeing this in 10.12.4?

No, but I see it in 10.12.5

Sorry, I meant 10.12.5.

I just tested this, and I am seeing it in 10.13.0, but not 10.12.5. Could you share what version of @firebase/app you have installed?

Looking at https://www.gstatic.com/firebasejs/10.13.0/firebase-app.js there is a console.log('heartbeats', (_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats);, but in https://www.gstatic.com/firebasejs/10.12.5/firebase-app.js there isn't.

dlarocque avatar Aug 19 '24 19:08 dlarocque

@dlarocque Apologies, I must've been mistaken. Indeed, 10.12.5 does NOT display the "heartbeats" logs.

ben519 avatar Aug 19 '24 19:08 ben519

Seeing this as well in version 10.13.0. We are using this in a nextjs app and I am seeing the message both on server side and client side.

heartbeats undefined

Coming from these lines:

export const auth = getAuth(app);

export const db = getFirestore(app);

saifbechan avatar Aug 19 '24 21:08 saifbechan

This was removed in https://github.com/firebase/firebase-js-sdk/pull/8437, which will be released next thursday (08/29). I'll keep this issue open until it's released. Thanks everyone for +1'ing this

dlarocque avatar Aug 19 '24 21:08 dlarocque

a tip: we have an eslint rule that errors on console.log so that it forces temporary usage. for permanent logs we use console.info/warn/error.

nickredmark avatar Aug 20 '24 12:08 nickredmark

This is a temporary workaround. Insert this snippet at the beginning of your main JavaScript file (e.g., index.js, main.js, etc.) or wherever you initialize Firebase:


// Save the original console.log function
const originalConsoleLog = console.log;

console.log = function(...args) {
// Check if the log message contains the word "heartbeats"
if (args.some(arg => typeof arg === 'string' && arg.includes('heartbeats'))) {
return; // Skip the log message
}

// Otherwise, use the original console.log
originalConsoleLog.apply(console, args);
};`

Xaypanya avatar Aug 24 '24 16:08 Xaypanya

This is super annoying. How can this happen?

flomoto avatar Aug 25 '24 14:08 flomoto

doesn't eslint caches this kind of things? how did it pass the CI? (asking for next time)

erlichmen avatar Aug 26 '24 06:08 erlichmen

Great! I'm looking forward to the update

This was removed in #8437, which will be released next thursday (08/29). I'll keep this issue open until it's released. Thanks everyone for +1'ing this

RicardoESH avatar Aug 28 '24 17:08 RicardoESH

The fix for this was released in 10.13.1 today.

dlarocque avatar Aug 29 '24 15:08 dlarocque

Great Success

Kronenberg avatar Sep 12 '24 12:09 Kronenberg