Skip to content

Log incorrectly prints [Circular] for object property when it shares reference with another property in the same object #1510

Closed
@brjakab

Description

@brjakab

Related issues

[REQUIRED] Version info

node: 18.19.0

firebase-functions: 4.6.0

firebase-tools: 12.9.1

firebase-admin: 11.11.0

[REQUIRED] Test case

My function is the following:

import { onCall } from "firebase-functions/v2/https";
import { logger } from "firebase-functions/v2";

export const testFunction = onCall(
  {
    region: "europe-west1",
  },
  (request) => {
    const commonData = { foo: "bar" }
    const obj1 = {
      data: commonData,

    }
    const obj2 = {
      data: commonData,

    }
    logger.debug("TEST 1", { obj1, obj2 })
  }
);

[REQUIRED] Steps to reproduce

  • Call the function
  • View the logs

[REQUIRED] Expected behavior

When calling the function (e.g. locally) it should log with the json payload:

{
  "obj1": { "data": { "foo": "bar" } },
  "obj2": { "data": { "foo": "bar" } },
  "severity": "DEBUG",
  "message": "TEST 1"
}

[REQUIRED] Actual behavior

Instead it prints the following payload:

{
  "obj1": { "data": { "foo": "bar" } },
  "obj2": { "data": "[Circular]" },
  "severity": "DEBUG",
  "message": "TEST 1"
}

Were you able to successfully deploy your functions?

Yes, I had the same issue when viewing the logs in the log explorer.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions