Exception object being truncated with @sentry/browser


#1

Hi,
I’m using the @sentry/browser SDK. Our exception messages are being truncated when they get sent to Sentry. I’m using Sentry by calling Sentry.captureException with an Error object as an argument. Here is an example Error object, as printed by console.log before it goes to Sentry:

Error: "[API]", "errors", [
  "bundle",
  [
    {
      "id": [
        "id/c",
        "1KuTtXoBt2asywAKEF6QdX"
      ]
    },
    null,
    5
  ]
], "in:", 41, "ms, errors:", [
  {
    "message": "note not found",
    "locations": [
      {
        "line": 1,
        "column": 24
      }
    ],
    "path": [
      "bundle"
    ]
  }
]
    at index.ts:51
    at Object.loggy [as warn] (config.ts:154)
    at MessageClient.<anonymous> (message_client.ts:289)
    at Generator.next (<anonymous>)
    at fulfilled (tslib.es6.js:68)

Here’s the example error as it shows up in the Sentry UI:

"[API]", "errors", [
  "bundle",
  [
    {
      "id": [
        "id/c",
        "1KuTtXoBt2asywAKEF6QdX"
      ]
    },
    null,
    5
  ]
], "in:", 41, "ms, errors:", [
  {
    "message": "note not found",
    "locations": [
      {
        "...

I can see that this matches what is being sent to Sentry in the request payload. Why is the error message being cut off? How can I get the full error message to be sent to Sentry?


#2

For what it’s worth, this is how I’m initializing Sentry:

    Sentry.init({                                                                                                                              
      dsn: cfg.SENTRY_DSN,                                                                                                               
      environment: cfg.RELEASE_ENV,                                                                                                      
      release: cfg.CLIENT_VERSION                                                                                                        
    })

#3

We are truncating after 250 chars.
We will make this configurable, can is it possible to show how your capture* looks like and what kind of error you are logging?


#4

We have a logger that gets created when the server starts. If the server is running in production (process.env.NODE_ENV === ‘production’), then we initialize Sentry and any errors that would normally get printed with console.error or console.warn get sent to Sentry like this:

  if (process.env.NODE_ENV === 'production') {                                                               
    const err = new Error(args.map(a => JSON.stringify(a, null, 2)).join(', '))                              
    Sentry.captureException(err)                                                                             
  }

#5

Thanks for the help, by the way. Do you know roughly when the change to make MAX_URL_LENGTH configurable will be available? I can change that line locally for now so our error messages are no longer being truncated.


#6

Here is the PR, it will land with v5