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

Error logs always show up in Cloud Error Reporting #1141

Merged
merged 4 commits into from Jun 17, 2022

Conversation

inlined
Copy link
Member

@inlined inlined commented Jun 15, 2022

Fixes #954.

  1. Removed support for Node 8 and 10 unstructured logging since we no longer support those versions of Node.
  2. Wrap all logging.error messages in an Error if none of the args are an error.

(2) makes sure that we get a stack trace in the log message, which is required for the Cloud Run data plane to send the log line to Cloud Error Reporting, where it shows up in the Firebase "Health" tab.

Tested with the following sample:

import { onRequest } from 'firebase-functions/v2/https';
import * as logger from 'firebase-functions/logger';

export const func = onRequest((req, res) => {
    logger.info("This is an info log");
    logger.error("This is an error log");
    logger.info("This is an info log with an error suffix", new Error("suffix"));
    logger.error("This is an error log with an error suffix", new Error("suffix"));
    res.send("OK");
    throw new Error("This is an unhandled error");
});

Cloud error reporting recorded all logger.error lines and the unhandled exception. The case with an Error suffix did not nest errors, which would cause the stack trace to be repeated.

@inlined inlined merged commit ea5edf9 into launch.next Jun 17, 2022
@inlined inlined deleted the inlined.error-logging branch June 17, 2022 20:52
@taeold taeold added this to the v4 milestone Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants