   updateTimeout: () ->
     return if not @timeoutValue
     clearTimeout @timeoutTimer
-    @timeoutTimer = setTimeout(@onTimeout.bind(@), @timeoutValue)
+    @timeoutTimer = setTimeout (@onTimeout.bind @), @timeoutValue
 
   onTimeout: () ->
     delete @gearman.currentJobs[@handle] if @handle

    @aborted = true

  receiveHandle: (handle) ->
    if handle
      @handle = handle
      @gearman.currentJobs[handle] = @
    else
      @emit "error", new Error("Invalid response from server")

module.exports = Job

class Job extends Stream
  constructor: (@gearman, @name, @payload) ->
    @timeoutTimer = null
    @gearman.sendCommand "SUBMIT_JOB", @name, false, @payload, @receiveHandle.bind @

  setTimeout: (timeout, timeoutCallback) ->
    @timeoutValue = timeout
