@belmonddev/catch-request-express-middleware 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +4 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -111,11 +111,11 @@ const callReceivedCbs = (req, res, requestReceivedCb, body) => {
111
111
  });
112
112
 
113
113
  if (responseCb) {
114
- res.setMaxListeners(100);
115
- if (res.writableFinished) {
114
+ req.socket.setMaxListeners(100);
115
+ if (req.socketClosed) {
116
116
  callResponseCb(responseCb, res);
117
117
  } else {
118
- res.on('finish', () => {
118
+ req.socket.on('close', () => {
119
119
  callResponseCb(responseCb, res);
120
120
  });
121
121
  }
@@ -135,6 +135,7 @@ const catchExpressReceivedRequest = (req, res, requestReceivedCb) => {
135
135
  if (!res.bodyWritten.length) {
136
136
  res.bodyWritten = firstData.split('\r\n\r\n')?.[1];
137
137
  }
138
+ req.socketClosed = true;
138
139
  }
139
140
  });
140
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belmonddev/catch-request-express-middleware",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "nodemon -L --experimental-specifier-resolution=node ./src/index.js"