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

Wrap all heartbeats methods in try/catch #8425

Merged
merged 2 commits into from
Aug 14, 2024
Merged

Wrap all heartbeats methods in try/catch #8425

merged 2 commits into from
Aug 14, 2024

Conversation

hsubox76
Copy link
Contributor

Heartbeat code should never throw and interfere with developer app operation. This PR wraps the two main heartbeat methods, triggerHeartbeat() and getHeartbeatsHeader() in try/catch blocks that hopefully catch unexpected errors in uncommon environments and logs a console.warn() instead.

I've been told in previous issues that thrown errors cause a lot of noise in Sentry logs (plus interrupting the app) while a console.warn() does not clog up Sentry logs, so I think this is a good compromise to avoid swallowing any fixable errors that we might want to know about.

Fixes #8407

Copy link

changeset-bot bot commented Aug 14, 2024

🦋 Changeset detected

Latest commit: 27eba97

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/app Patch
@firebase/app-compat Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hsubox76 hsubox76 marked this pull request as ready for review August 14, 2024 16:45
@hsubox76 hsubox76 requested review from a team as code owners August 14, 2024 16:45
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 14, 2024

Size Report 1

Affected Products

  • @firebase/app

    TypeBase (cfca9c6)Merge (9cabc20)Diff
    browser18.3 kB18.4 kB+164 B (+0.9%)
    esm523.8 kB24.1 kB+296 B (+1.2%)
    main24.9 kB25.2 kB+296 B (+1.2%)
    module18.3 kB18.4 kB+164 B (+0.9%)
  • bundle

    46 size changes

    TypeBase (cfca9c6)Merge (9cabc20)Diff
    analytics (logEvent)44.5 kB44.6 kB+152 B (+0.3%)
    app-check (CustomProvider)37.3 kB37.5 kB+152 B (+0.4%)
    app-check (ReCaptchaEnterpriseProvider)39.9 kB40.0 kB+152 B (+0.4%)
    app-check (ReCaptchaV3Provider)39.8 kB40.0 kB+152 B (+0.4%)
    auth (Anonymous)76.0 kB76.2 kB+152 B (+0.2%)
    auth (EmailAndPassword)84.3 kB84.5 kB+152 B (+0.2%)
    auth (GoogleFBTwitterGitHubPopup)103 kB103 kB+152 B (+0.1%)
    auth (GooglePopup)100 kB100 kB+152 B (+0.2%)
    auth (GoogleRedirect)100 kB100 kB+152 B (+0.2%)
    auth (Phone)86.7 kB86.8 kB+152 B (+0.2%)
    database (Append to a list of data)149 kB149 kB+152 B (+0.1%)
    database (Filtering data)148 kB148 kB+152 B (+0.1%)
    database (Listen for child events)164 kB165 kB+152 B (+0.1%)
    database (Listen for value events + Detach listeners)164 kB164 kB+152 B (+0.1%)
    database (Listen for value events)164 kB164 kB+152 B (+0.1%)
    database (Read data once)164 kB164 kB+152 B (+0.1%)
    database (Save data as transactions)166 kB166 kB+152 B (+0.1%)
    database (Sort data)150 kB150 kB+152 B (+0.1%)
    database (Write data)148 kB148 kB+152 B (+0.1%)
    firestore (CSI Auto Indexing Disable and Delete)270 kB270 kB+152 B (+0.1%)
    firestore (CSI Auto Indexing Enable)270 kB270 kB+152 B (+0.1%)
    firestore (Persistence)305 kB305 kB+152 B (+0.0%)
    firestore (Query Cursors)242 kB242 kB+152 B (+0.1%)
    firestore (Query)240 kB240 kB+152 B (+0.1%)
    firestore (Read data once)228 kB228 kB+152 B (+0.1%)
    firestore (Read Write w Persistence)325 kB325 kB+152 B (+0.0%)
    firestore (Realtime updates)230 kB230 kB+152 B (+0.1%)
    firestore (Transaction)207 kB207 kB+152 B (+0.1%)
    firestore (Write data)207 kB207 kB+152 B (+0.1%)
    firestore-lite (Query Cursors)91.2 kB91.3 kB+152 B (+0.2%)
    firestore-lite (Query)87.3 kB87.5 kB+152 B (+0.2%)
    firestore-lite (Read data once)62.8 kB63.0 kB+152 B (+0.2%)
    firestore-lite (Transaction)88.1 kB88.2 kB+152 B (+0.2%)
    firestore-lite (Write data)72.4 kB72.6 kB+152 B (+0.2%)
    functions (call)31.9 kB32.0 kB+152 B (+0.5%)
    messaging (send + receive)46.9 kB47.0 kB+152 B (+0.3%)
    performance (trace)51.7 kB51.8 kB+152 B (+0.3%)
    remote-config (getAndFetch)46.2 kB46.4 kB+152 B (+0.3%)
    storage (getBytes)42.0 kB42.2 kB+152 B (+0.4%)
    storage (getDownloadURL)44.1 kB44.2 kB+152 B (+0.3%)
    storage (getMetadata)43.5 kB43.7 kB+152 B (+0.3%)
    storage (list + listAll)43.0 kB43.1 kB+152 B (+0.4%)
    storage (updateMetadata)43.8 kB43.9 kB+152 B (+0.3%)
    storage (uploadBytes)48.7 kB48.8 kB+152 B (+0.3%)
    storage (uploadBytesResumable)58.6 kB58.8 kB+152 B (+0.3%)
    storage (uploadString)48.9 kB49.0 kB+152 B (+0.3%)

  • firebase

    TypeBase (cfca9c6)Merge (9cabc20)Diff
    firebase-app-compat.js31.7 kB31.8 kB+169 B (+0.5%)
    firebase-app.js102 kB103 kB+592 B (+0.6%)
    firebase-compat.js788 kB788 kB+171 B (+0.0%)
    firebase-performance-standalone-compat.es2017.js93.5 kB93.7 kB+164 B (+0.2%)
    firebase-performance-standalone-compat.js70.6 kB70.8 kB+256 B (+0.4%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/lLPV8vb2tP.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 14, 2024

Size Analysis Report 1

This report is too large (150,977 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/utvXAXLYyw.html

@hsubox76 hsubox76 merged commit 6d6ce81 into main Aug 14, 2024
43 checks passed
@hsubox76 hsubox76 deleted the ch-hb-fix branch August 14, 2024 18:25
@google-oss-bot google-oss-bot mentioned this pull request Aug 14, 2024
// service, not the browser user agent.
const agent = platformLogger.getPlatformInfoString();
const date = getUTCDateString();
console.log('heartbeats', this._heartbeatsCache?.heartbeats);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional or an oversight?

Copy link

@robertIsaac robertIsaac Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @hsubox76
this is showing in our production logs now, can you please remove it
it took me a while to see where is it coming from
I updated many dependencies and wasn't sure which one caused these logs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating Firebase to version 10.13.0, I'm seeing a console log message that says heartbeats undefined. It would be great if the log could be removed!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link

@gustavopch gustavopch Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't update to 10.13.0 because of this as it adds a lot of noise to my frontend monitoring logs.

EDIT: they'll release a fix soon: #8436 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GogoVega @robertIsaac @Tosters @BenaymS @gustavopch

This was removed in 10.13.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
10 participants