[go: nahoru, domu]

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

Structured logging error context not being serialized #1556

Closed
kdawgwilk opened this issue Apr 28, 2024 · 3 comments
Closed

Structured logging error context not being serialized #1556

kdawgwilk opened this issue Apr 28, 2024 · 3 comments

Comments

@kdawgwilk
Copy link

Related issues

[REQUIRED] Version info

node:

v18.19.1

firebase-functions:

4.9.0

firebase-tools:

13.3.1

firebase-admin:

12.1.0

[REQUIRED] Test case

index.ts

export const testErrorContext = onRequest((req, res) => {
  try {
    throw new Error('Some Random Error')
  } catch (err) {
    error('Error running some code', {
      error: err,
      tenantId: myInternalContext.tenantId,
    });
  }
  res.status(200).send('Function ran!')
});

[REQUIRED] Steps to reproduce

  • Call the above testErrorContext
  • View the logs

[REQUIRED] Expected behavior

The jsonPayload.error field would have the serialized error info

[REQUIRED] Actual behavior

The jsonPayload.error field comes through as
image

Were you able to successfully deploy your functions?

Yes

@google-oss-bot
Copy link
Collaborator

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@kdawgwilk
Copy link
Author

It looks like this might be because the firebase-functions/logger has special case handling for errors passed as the context object but how do i add my own context to that?

@kdawgwilk
Copy link
Author

I ended up using the serialize-error library and handling the serialization myself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants