paldepind / functional-frontend-architecture

A functional frontend framework.
MIT License
1.44k stars 87 forks source link

abort event listener registration error #27

Open emarteca opened 4 years ago

emarteca commented 4 years ago

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 16 in examples/file-uploader/server.js, on the registration of the “abort” event.

The reason I believe this is indicative of an error is as follows (from looking at the nodejs http API documentation): The req variable, as the first argument to the callback of createServer (on line 14), is an object of type http.IncomingMessage. However, the “abort” event is emitted on http.ClientRequest, and not http.IncomingMessage.

Since there is an event “aborted” emitted on http.IncomingMessage, my guess is that the code should be req.on(“aborted”, …) instead.

Thanks!