 
 module.exports = ({host, port, timeout}) ->
   return ({context, query}, callback) ->
+    callbacked = false
     path = '/druid/v2/'
     if query.queryType is 'heatmap'
       # Druid is f-ed

        socket.on 'timeout', -> req.abort()

    req.on 'error', (e) ->
      callback(e)
      return

    req.write(queryBuffer.toString('utf-8'))

        return

      response.on 'close', (err) ->
        return if callbacked
        callback({
          error: 'close'
          message: err
        })
        callbacked = true
        return

      response.on 'end', ->
        chunks = chunks.join('')
        if response.statusCode isnt 200
          return if callbacked
          callback({
            error: 'bad status code'
            detail: response.statusCode
            message: chunks
          })
          callbacked = true
          return

        try
          chunks = JSON.parse(chunks)
        catch e
          return if callbacked
          callback({
            error: 'json parse'
            message: e.message
          })
          callbacked = true
          return

        return if callbacked
        callback(null, chunks)
        callbacked = true
        return
      return
    )
