Skip to content

Commit 08afb8b

Browse files
author
Christian Stimming
committed
Fix missing error if initial connection cannot be established.
E.g. if the IP address of the server is wrong: Currently the socket setup just runs forever, but the situation of a wrong server address should better be handled somehow.
1 parent aa077d0 commit 08afb8b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

dcom/rpc/stub.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Stub extends Events.EventEmitter {
8787
transport = this.endpoint.transport;
8888
await transport.attach()
8989
.catch(function(reject) {
90-
debug(reject);
90+
throw new Error(reject)
9191
});
9292
}
9393

dcom/transport/comtransport.js

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class ComTransport extends events.EventEmitter
108108

109109
channel.on('error', function(data){
110110
self.emit('disconnected');
111+
reject(data)
111112
});
112113

113114
channel.on('close', function(){
@@ -116,7 +117,10 @@ class ComTransport extends events.EventEmitter
116117
}
117118
});
118119

120+
const connectFailedTimer = setTimeout(() =>
121+
channel.emit('error', 'Connection could not be established'), self.timeout)
119122
channel.connect(Number.parseInt(self.port), self.host, () => {
123+
clearTimeout(connectFailedTimer)
120124
self.attached = true;
121125
channel.setKeepAlive(true);
122126
self.channelWrapper = channel;

0 commit comments

Comments
 (0)