Are express.js Request events documented anywhere?

Viewed 3916

It seems to be common community knowledge that Express Request objects have events like req.on('data', …) and req.on('end', …), but the official documentation – https://expressjs.com/en/api.html – makes no mention of these events.

Are Express' Request events documented anywhere? And what – if any – guarantees are made about them?

2 Answers

Look at the documentation for the request object:

The req object is an enhanced version of Node’s own request object and supports all built-in fields and methods.

This then says, for example:

In a successful request, the following events will be emitted in the following order:

  • 'socket'
  • 'response'
  • 'data' any number of times, on the res object ('data' will not be emitted at all if the response body is empty, for instance, in most redirects)
  • 'end' on the res object
  • 'close'
Related