Because toJSON works recursively dprof can reach a stack overflow. This could be fixed by flattening the format, such the root is a uid map and node.children is a uid list.
Root {
version: String, // the version of dprof there generated this JSON file
total: Number, // execution time in nanoseconds
root: {
Number(uid): Node, ...
}
}
Node {
name: String, // Handle name of the async operation
stack: [ // Contains the stack leading up to the async operation
{
description: String,
filename: String,
column: Number,
line: Number
}, ...
],
init: Number, // Timestamp for when the async operation is requested.
before: [Number], // Timestamp for when the callback is about to be called.
// This is an array because a callback may be called more
// than once.
after: [Number], // Timestamp for when the callback is finished.
// All timestamps are relative to the process startup time
// and the unit is nanoseconds.
unrefed: Boolean, // `true` if the handle will not keep the event loop open.
children: [ // Shows async operations created in the callback
uid, ...
]
}
Because
toJSONworks recursivelydprofcan reach a stack overflow. This could be fixed by flattening the format, such the root is a uid map andnode.childrenis a uid list.