• Stars
    star
    166
  • Rank 223,408 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Detect any handles leaked in node

leaked-handles

Detect any handles leaked in node

Example

require("leaked-handles");

Example output.

no of handles 1

timer handle (`setTimeout(any, 1000)`)
timer handle leaked at one of: 
    at Test.t (/home/raynos/uber/leaked-handles/test/leak-timer.js:10:17)
timer listener function any() {}


no of handles 1
tcp handle leaked at one of: 
    at Test.t (/home/raynos/uber/leaked-handles/test/leak-tcp.js:9:22)
tcp stream { fd: 10,
  readable: false,
  writable: true,
  address: { address: '127.0.0.1', family: 'IPv4', port: 39126 } }

Options

require('leaked-handles').set({
    fullStack: true, // use full stack traces
    timeout: 30000, // run every 30 seconds instead of 5.
    debugSockets: true // pretty print tcp thrown exceptions.
});

Explanation

Add this to the TOP of your tests as the very first require.

This will now print any handles that keep your process open.

It has pretty printing of some handles including

  • timers. Tells the timeout and the file that leaked it.
  • child processes. Tells you that a handle is leaked because of a spawned child process and the pid.
  • stream. Prints the fact the handle is a stream and the fd.
  • child process stream. Prints the fact the handle is a stream and specifically one of the three fds for the child process.

Debugging tips

When you see a timer, it will print the file, so go fix it!

When you see a child process it prints the pid. Run ps -p {pid} and figure out what kind of child process it is.

When you see a stream it prints the fd. Run lsof -p {process.pid} to see what fds your test process has open and see if you can figure out what the hell it is.

When you see a child process stream, go find the child process that leaked. If no child process leaked then again, use lsof to lookup up the fd.

Installation

npm install leaked-handles

Tests

npm test

Contributors

  • Raynos

MIT Licenced

More Repositories

1

mercury

A truly modular frontend framework
JavaScript
2,822
star
2

http-framework

A web framework based purely on require('http')
JavaScript
523
star
3

xtend

extend like a boss
JavaScript
305
star
4

global

Require global variables
JavaScript
252
star
5

main-loop

A rendering loop for diffable UIs
JavaScript
172
star
6

DOM-shim

Shims out the entire DOM4 API
JavaScript
154
star
7

function-bind

JavaScript
136
star
8

error

Error handling utilities for node
JavaScript
123
star
9

body

Body parsing
JavaScript
120
star
10

after

All the flow control you'll ever need
JavaScript
116
star
11

min-document

A minimal DOM implementation
JavaScript
108
star
12

jsig

From scratch type-checker
JavaScript
104
star
13

duplexer

Creates a duplex stream
JavaScript
95
star
14

observ

A observable value representation
JavaScript
74
star
15

observ-struct

An object with observable key value pairs
JavaScript
72
star
16

virtual-hyperscript

A DSL for creating virtual trees
JavaScript
60
star
17

dom-delegator

Decorate elements with delegated events
JavaScript
58
star
18

topology

Different network topologies
JavaScript
57
star
19

continuable

Idea for callbacks as values
JavaScript
54
star
20

live-reload

A live reload server & client
JavaScript
51
star
21

pd

Property Descriptors made easy
JavaScript
44
star
22

engine.io-stream

Wrap engine.io in a real stream interface
JavaScript
44
star
23

vdom-thunk

A thunk optimization for virtual-dom
JavaScript
42
star
24

stream-chat

Alpha chat app using streams for communication
JavaScript
40
star
25

resultify

Handle errors with async/await without try/catch.
JavaScript
38
star
26

graphics

Efficient data structures that represent renderable scenes
JavaScript
38
star
27

safe-json-parse

Parse JSON safely without throwing
JavaScript
36
star
28

webrtc-stream

WebRTC demo
JavaScript
34
star
29

level-livefeed

Live query a range in leveldb
JavaScript
34
star
30

http-works

A workshopper for http framework
JavaScript
32
star
31

tsdocstandard

Standard but also use TypeScript on JS files with jsdoc.
JavaScript
31
star
32

discovery-network

A peer to peer discovery network
JavaScript
31
star
33

geval

JavaScript
30
star
34

corsify

CORS up a route handler
JavaScript
29
star
35

itape

An interactive tape runner.
JavaScript
27
star
36

send-data

send data through response
JavaScript
26
star
37

ncore

Core infrastructure for node.
JavaScript
26
star
38

observ-array

An array containing observable values
JavaScript
26
star
39

append-only

Append only scuttlebutt structure
JavaScript
25
star
40

jsonml-stringify

Convert jsonml arrays to html strings
JavaScript
22
star
41

eslint-plugin-perf-standard

A set of custom plugins to enforce high performance JS
JavaScript
21
star
42

routes-router

Simplest request handler possible
JavaScript
21
star
43

for-each

A better forEach
JavaScript
21
star
44

auth-stream

Authorize access before exposing a stream
JavaScript
21
star
45

value-event

Create DOM event handlers that write to listeners
JavaScript
21
star
46

boot

Shoe & mux demux with reconnect!
JavaScript
20
star
47

stream-router

Easily route mdm streams
JavaScript
19
star
48

jsconf2014-talk

Modular frontend with NPM & pals
JavaScript
19
star
49

raynos-blog

My blog
JavaScript
19
star
50

whatwg-streams

JavaScript
17
star
51

deep-merge

Deep merge objects with custom merging logic
JavaScript
17
star
52

map-async

Asynchronously map over a list
JavaScript
17
star
53

data-channel

Turn a data channel into a stream
JavaScript
17
star
54

gens

Experimental usage of generators
JavaScript
17
star
55

level-cache

An in memory cache on top of leveldb
JavaScript
17
star
56

npm-bin-deps

NPR allows you to run your CLI dependencies without having a copy in node_modules.
JavaScript
16
star
57

serve-browserify

HTTP handler for serving browserify bundles
JavaScript
16
star
58

delta-stream

A stream that emits deltas in change
JavaScript
15
star
59

examplifier

Turn bland source code into interactive demos
JavaScript
15
star
60

distributed-map

A distributed key value store in the browser
JavaScript
14
star
61

clientmongo

Use the mongo API in the browser
JavaScript
14
star
62

multi-channel-mdm

Create persisted channels to broadcast data!
JavaScript
14
star
63

buffer-stream

A duplex stream that buffers writes
JavaScript
14
star
64

chain-stream

Chain stream operations together
JavaScript
14
star
65

fake-s3

a fake s3 server for testing purposes.
JavaScript
13
star
66

signal-channel

A signal channel that empowers webrtc
JavaScript
13
star
67

levelidb

A levelup interface on top of indexeddb
JavaScript
12
star
68

level-write-stream

A writeStream implementation for leveldb
JavaScript
12
star
69

frontend-framework

Building frontend apps with small modules
JavaScript
12
star
70

reduce

A better [].reduce
JavaScript
12
star
71

browserify-server

spin up browserify demos real easy
JavaScript
12
star
72

format-stack

Formats a stack with colors
JavaScript
12
star
73

feature

Feature detection for host objects
JavaScript
12
star
74

hash-router

A frontend router for the hash change event
JavaScript
11
star
75

html-delegator

Decorate elements with delegated events
JavaScript
11
star
76

promise-stream

A Promises/A implementation based on streams
JavaScript
11
star
77

ready-signal

A ready signal. Wait for ready and signal it's ready
JavaScript
11
star
78

ev-store

Stores event listeners and event handles on a DOM object
JavaScript
11
star
79

weakmap-shim

JavaScript
10
star
80

to-array

Turn an array like into an array
JavaScript
10
star
81

term-color

A lighter weight alternative to chalk
JavaScript
9
star
82

static-config

JavaScript
9
star
83

npm-less

JavaScript
9
star
84

eventemitter-light

It's a light event emitter
JavaScript
9
star
85

expiry-model

A scuttlebutt model that expires keys
JavaScript
9
star
86

http-methods

Handle multiple methods elegantly
JavaScript
9
star
87

mux-demux-shoe

Shoe and mux-demux come together!
JavaScript
9
star
88

validate-form

JavaScript
9
star
89

iterators

iterate over collections asynchronously
JavaScript
8
star
90

fake-sqs

Runs a fake SQS server on a HTTP port.
JavaScript
8
star
91

redirecter

JavaScript
8
star
92

seaport-proxy

Proxy all the seaports!
JavaScript
8
star
93

request-proxy

A version of request that's local to a fixed base uri
JavaScript
8
star
94

pre-bundled

A tool that pre bundles and re publishes npm dependencies
JavaScript
8
star
95

mongo-col

mongodb collection wrapper
JavaScript
8
star
96

tape-harness

A helper to run integration tests against an application
JavaScript
8
star
97

sockjs-stream

A streaming API for sockjs
JavaScript
7
star
98

so642

JavaScript
7
star
99

add

Add two numbers
JavaScript
7
star
100

composite

Compose functions together
JavaScript
7
star