-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: memory leak with when using Http(s)Agent keepAlive=true (#391)
* create spec to reproduce memory leak * fix memory leak using keep-alive in nodejs * fix lint on spec support file * refactor test spec to improve readability * use explicit callback assignments instead of .bind * add spec for onRequestSocketAssigned calls * add changeset
- Loading branch information
1 parent
e01114f
commit 9da82f6
Showing
4 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'mappersmith': minor | ||
--- | ||
|
||
Fixes memory leak when using http(s) agent with keep-alive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import createManifest from 'spec/integration/support/manifest' | ||
|
||
import forge from 'src/index' | ||
|
||
export default function keepAlive(host, gateway) { | ||
return { | ||
verifySockets: (count, socketsReference) => { | ||
const socketOrigins = Object.keys(socketsReference) | ||
expect(socketOrigins.length).toBe(count) | ||
if (count === 0) return | ||
|
||
const sockets = socketsReference[socketOrigins[0]] | ||
expect(sockets.length).toBe(count) | ||
const socket = sockets[0] | ||
expect(socket.listenerCount('lookup')).toBe(count) | ||
expect(socket.listenerCount('connect')).toBe(count) | ||
}, | ||
callApiTwice: () => { | ||
const Client = forge(createManifest(host), gateway) | ||
return Client.Book.all().then(() => Client.Book.all()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters