Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function request(options, data = "") {
});

req.on("socket", (socket) => {
socket.setMaxListeners(100);
socket.on("lookup", () => {
dnsLookup = performance.now();
});
Expand Down
3 changes: 3 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('Speed Test CLI', () => {
on: jest.fn((event, callback) => {
if (event === 'socket') {
const mockSocket = {
setMaxListeners: jest.fn(),
on: jest.fn((socketEvent, socketCallback) => {
if (socketEvent === 'lookup') setTimeout(() => socketCallback(), 1);
if (socketEvent === 'connect') setTimeout(() => socketCallback(), 2);
Expand Down Expand Up @@ -206,6 +207,7 @@ describe('Speed Test CLI', () => {
on: jest.fn((event, callback) => {
if (event === 'socket') {
const mockSocket = {
setMaxListeners: jest.fn(),
on: jest.fn((socketEvent, socketCallback) => {
if (socketEvent === 'lookup') setTimeout(() => socketCallback(), 1);
if (socketEvent === 'connect') setTimeout(() => socketCallback(), 2);
Expand Down Expand Up @@ -255,6 +257,7 @@ describe('Speed Test CLI', () => {
on: jest.fn((event, callback) => {
if (event === 'socket') {
const mockSocket = {
setMaxListeners: jest.fn(),
on: jest.fn((socketEvent, socketCallback) => {
if (socketEvent === 'lookup') setTimeout(() => socketCallback(), 1);
if (socketEvent === 'connect') setTimeout(() => socketCallback(), 2);
Expand Down