mafintosh / mafintosh/why-is-node-running

Logging multiple times over the course of a programs lifetime

Open
#42 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.9k
Forks
52
PR merge metrics
No merged PRs in 30d

Description

With v2.0.3, invoking the exported log [disables the hook](https://github.com/mafintosh/why-is-node-running/blob/v2.0.3/index.js#L26). I needed a more complete picture of what was going on during closing of an application because the answer to "why is node running" kept changing. Hence, I tried to sample open handlers as shown below.

```javascript
for (let i = 0; i < 10; i++) {
setTimeout(log, (i + 1) * 500);
}
```

However, this was obviously not possible. It worked with the following patch, in case anyone also needs this, and I am lightly suggesting it as an addition.

```patch
--- index.js
+++ index.js
@@ -23,9 +23,8 @@
function whyIsNodeRunning (logger) {
if (!logger) logger = console

- hook.disable()
logger.error('There are %d handle(s) keeping the process running', active.size)
- for (const o of active.values()) printStacks(o)
+ for (const o of [...active.values()]) printStacks(o)

function printStacks (o) {
var stacks = o.stacks.slice(1).filter(function (s) {
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading index.js around whyIsNodeRunning and the hook handling described in the issue. Check how repeated calls to the exported log behave, then verify that sampling multiple times reports the current handles without stopping further tracking. The issue's patch shows the intended one-file scope and the relevant output path.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.