Debugging a timeout leak #4695
Unanswered
jeremy-rifkin
asked this question in
Q&A
Replies: 0 comments 1 reply
-
Realistically, the best way might be to override the A proof of concept would be (this would have to be tied into the Prometheus client): const _setTimeout = setTimeout;
getStackTrace = function () {
var obj = {};
Error.captureStackTrace(obj, getStackTrace);
return obj.stack
.split("\n")
.slice(1)
.map((line) => line.trim());
};
const counter = PromClinet.Counter({
name: 'metric_name',
help: 'metric_help',
labelNames: ['location'] as const,
});
setTimeout = function (fn, delay) {
const location = getStackTrace().slice(1, 3).join("\n"); // Get the last 2 lines, maybe needs to be bumped up if it lies inside some promise code
counter.labels({ location }).inc();
return _setTimeout(fn, delay);
};
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I think I have a timeout leak somewhere in my project:
Data from the node prometheus client which is looking at
process.getActiveResourcesInfo()
.I know of a lot of places where timeouts are created in my project but I can't find anything that could cause timeouts to build up like this, unless timeouts aren't cleared from the event loop when they expire. I can't rule out library code either.
Are there any tools I can use for figuring out where these timers are being created?
Beta Was this translation helpful? Give feedback.
All reactions