mattinsler / longjohn

Long stack traces for node.js inspired by https://github.com/tlrobinson/long-stack-traces
MIT License
836 stars 38 forks source link

No limit on serialization of error #15

Closed cdnbacon closed 9 years ago

cdnbacon commented 11 years ago

Every so often, we'll run into an error that longjohn tries to serialize, and in attempting to do so will peg the CPU and gobble up RAM (like 1+GB).

It seems like it attempts to serialize our entire application in a single Object graph...

uncaughtException: { [Error: Invalid timestamp. Please provide timezone as fallback]
  __cached_trace__: 
   [ { receiver: 
        { localTime: [Function],
          humanizeDuration: [Function] },
       fun: [Function],
       pos: 401 },
     { receiver: undefined,
       fun: [Function: grouper],
       pos: 4432 },
     { receiver: 
        { ArrayBuffer: [Function: ArrayBuffer],
          Int8Array: { [Function: Int8Array] BYTES_PER_ELEMENT: 1 },
          Uint8Array: { [Function: Uint8Array] BYTES_PER_ELEMENT: 1 },
          Uint8ClampedArray: { [Function: Uint8ClampedArray] BYTES_PER_ELEMENT: 1 },
          Int16Array: { [Function: Int16Array] BYTES_PER_ELEMENT: 2 },
          Uint16Array: { [Function: Uint16Array] BYTES_PER_ELEMENT: 2 },
          Int32Array: { [Function: Int32Array] BYTES_PER_ELEMENT: 4 },
          Uint32Array: { [Function: Uint32Array] BYTES_PER_ELEMENT: 4 },
          Float32Array: { [Function: Float32Array] BYTES_PER_ELEMENT: 4 },
          Float64Array: { [Function: Float64Array] BYTES_PER_ELEMENT: 8 },
          DataView: [Function: DataView],
          global: [Circular],
          process: 
           { title: 'node',
             version: 'v0.8.21',
             moduleLoadList: 
              [ 'Binding evals',
                'Binding natives',
                'NativeModule events',
                'NativeModule buffer',
                'Binding buffer',
                'NativeModule assert',
                // several thousands of additional lines omitted ...

It might be worth using util's inspect to mitigate this.

ibash commented 11 years ago

I'm running into a similar problem where our logger (winston) tries to JSONify the error, and decycles the whole object graph. Is there a way within longjohn to make sure it doesn't reach the node process?

mattinsler commented 11 years ago

Oof, I'm so sorry that happens! What version of node are you running?

ibash commented 11 years ago

@mattinsler v0.8.15

robertherber commented 11 years ago

@mattinsler I have the same issue. Have you had any time to look into it?

derjust commented 9 years ago

Same here. +1 as this is really a bocker to use with winston....