caolan / caolan/highland

how to destroy a stream cleanly

Open
#489 14 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Hi All, here is my issue

**many clients will connect and pipe their data into mainStream**

```
net.createServer (socket) ->
clientStream = h(socket)
clientStream.fork().pipe mainStream
```

However, my question is what happens the the socket closes, does highland destroys clientStream and unpipes it from mainStream?

When i disconnect and connect the client 11 times i get this warning:

```
(node) warning: possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Stream.addListener (events.js:239:17)
at pipeStream (/Users/benjaminhon/Developer/IndoorLocalization/server/localization-server/node_modules/highland/lib/index.js:501:10)
at Stream.pipe (/Users/benjaminhon/Developer/IndoorLocalization/server/localization-server/node_modules/highland/lib/index.js:1008:12)
```

it seems some event listeners are not removed? do i need to do this manually and unripe manually?

Thx

Contributor guide

Open the contributing guide

Research direction

Start with the reported reproduction: net.createServer, clientStream.fork().pipe(mainStream), and 11 connect/disconnect cycles. Read node_modules/highland/lib/index.js around pipeStream at line 501 and Stream.pipe at line 1008, then verify whether the drain listeners and stream connections are cleaned up; done means the warning no longer appears after repeated disconnects.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.