Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

why-is-node-running

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

why-is-node-running - npm Package Compare versions

Comparing version 2.3.0 to 3.0.0

8

cli.js
#!/usr/bin/env node
var spawn = require('child_process').spawn
var path = require('path')
import { spawn } from 'node:child_process'
import path from 'node:path'

@@ -12,4 +12,4 @@ var prog = path.resolve(process.argv[2])

var nodeArgs = [
'-r',
path.join(__dirname, 'include.js')
'--import',
path.join(import.meta.dirname, 'include.js')
]

@@ -16,0 +16,0 @@ var nodeOpts = { stdio: 'inherit' }

@@ -1,3 +0,3 @@

var log = require('./')
var net = require('net')
import why from './index.js'
import net from 'node:net'

@@ -14,3 +14,3 @@ function createServer () {

setTimeout(function () {
log()
why()
}, 100)

@@ -1,3 +0,4 @@

var why = require('./')
import why from './index.js'
import siginfo from 'siginfo'
require('siginfo')(why, true)
siginfo(why, true)

@@ -1,5 +0,7 @@

var asyncHooks = require('async_hooks')
var stackback = require('stackback')
var path = require('path')
var fs = require('fs')
import asyncHooks from 'node:async_hooks'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import stackback from 'stackback'
var sep = path.sep

@@ -22,5 +24,4 @@

hook.enable()
module.exports = whyIsNodeRunning
function whyIsNodeRunning (logger) {
export default function whyIsNodeRunning (logger) {
if (!logger) logger = console

@@ -54,9 +55,9 @@

stacks.forEach(function (s) {
var pad = (s.getFileName() + ':' + s.getLineNumber()).replace(/./g, ' ')
var pad = (normalizeFileName(s.getFileName()) + ':' + s.getLineNumber()).replace(/./g, ' ')
if (pad.length > padding.length) padding = pad
})
stacks.forEach(function (s) {
var prefix = s.getFileName() + ':' + s.getLineNumber()
var prefix = normalizeFileName(s.getFileName()) + ':' + s.getLineNumber()
try {
var src = fs.readFileSync(s.getFileName(), 'utf-8').split(/\n|\r\n/)
var src = fs.readFileSync(normalizeFileName(s.getFileName()), 'utf-8').split(/\n|\r\n/)
logger.error(prefix + padding.slice(prefix.length) + ' - ' + src[s.getLineNumber() - 1].trim())

@@ -70,1 +71,5 @@ } catch (e) {

}
function normalizeFileName(fileName) {
return fileName.startsWith('file://') ? fileURLToPath(fileName) : fileName
}
{
"name": "why-is-node-running",
"version": "2.3.0",
"type": "module",
"version": "3.0.0",
"description": "Node is running but you don't know why? why-is-node-running is here to help you.",
"main": "index.js",
"exports": {
".": "./index.js",
"./includes": "./include.js"
},
"dependencies": {

@@ -14,3 +18,3 @@ "siginfo": "^2.0.0",

"engines": {
"node": ">=8"
"node": ">=20.11"
},

@@ -17,0 +21,0 @@ "repository": {

@@ -22,4 +22,4 @@ # why-is-node-running

```js
const log = require('why-is-node-running') // should be your first require
const net = require('net')
import why from 'why-is-node-running' // should be your first import
import net from 'node:net'

@@ -36,3 +36,3 @@ function createServer () {

setTimeout(function () {
log() // logs out active handles that are keeping node running
why() // logs out active handles that are keeping node running
}, 100)

@@ -94,8 +94,8 @@ ```

## Require CLI Option
## Import CLI Option
You can also use the node `-r` option to include `why-is-node-running`:
You can also use Node's [`--import`](https://nodejs.org/api/cli.html#--importmodule) option to preload `why-is-node-running`:
```bash
node -r why-is-node-running/include /path/to/some/file.js
node --import why-is-node-running/include /path/to/some/file.js
```

@@ -102,0 +102,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc