Skip to content

Commit 547445c

Browse files
authored
Merge pull request #125 from pierotofy/drop
Emulate socket drop
2 parents b0ed6ae + 0f2855c commit 547445c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libs/proxy.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ module.exports = {
162162

163163
// Listen for the `error` event on `proxy`.
164164
proxy.on('error', function (err, req, res) {
165-
json(res, {error: `Proxy redirect error: ${err.message}`});
165+
// If the error is caused by a connection issue,
166+
// we actually simulate the same behavior by dropping the connection
167+
// because returning an error could make a NodeODM client assume that something failed
168+
if (res.socket && (err.code === 'ECONNRESET' || err.code === 'ECONNREFUSED')){
169+
logger.warn(`Proxy redirect error: ${err.message}`);
170+
res.socket.destroy();
171+
}else{
172+
json(res, {error: `Proxy redirect error: ${err.message}`});
173+
}
166174
});
167175

168176
// Added for CORS support

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ClusterODM",
3-
"version": "1.5.4",
3+
"version": "1.5.5",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)