Skip to content

end event listener registration error #80

Closed
@emarteca

Description

@emarteca

Hi all, I've been working on a tool to identify instances of events registered to the wrong object in uses of some JavaScript event-driven APIs, as part of a research project.
The tool flagged line 74 in test/bench.js, on the registration of the "end" event.

The reason I believe this is an error as follows (from looking at the nodejs http API documentation, particularly https://nodejs.org/api/http.html#http_http_get_options_callback):
The return of https.get(...) is an http.ClientRequest object, and res, as the argument to the callback handleResponse passed to get, is an http.IncomingMessage.
“end” is an event on http.IncomingMessage, and not on http.ClientRequest (you even have a registration of a listener for “end” on res, in the body of the handleResponse callback).

A common event indicative of an error to listen to on http.ClientRequest is “timeout”, so my guess is that maybe your registration on line 74 should be for “timeout” instead of “end”.

Metadata

Metadata

Assignees

Labels

Category: BuildAbout the test, benchmark or release process

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions