Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/error on no server #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/gearmanode/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ Client.prototype.submitJob = function(name, payload, options) {
jobServer.send(packet, jsSendCallback);
}

tryToSend();
// Allow to add an handler to the job on 'error' event
process.nextTick(tryToSend);
return job;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/gearmanode/job-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ JobServer.prototype.connect = function (callback) {
// emitted when an error occurs
this.socket.on('error', function (err) {
JobServer.logger.log('error', 'socket error:', err);
var connected = self.connected;
// ensures that no more I/O activity happens on this socket
self.socket.destroy();

Expand All @@ -122,7 +123,9 @@ JobServer.prototype.connect = function (callback) {
self.clientOrWorker.emit('socketError', self.getUid(), err); // trigger event
self.disconnect(err);

callback(err);
if (!connected) {
callback(err);
}
});

this.socket.on('data', function (chunk) {
Expand Down