       req.on 'error', (err) ->
         err.url = url
         error = err
-      req.on 'end', ->
+      req.on 'end', =>
+        delete @inFlight[url]
         if error
           tmpFile.unlink()
           onError error

  description: 'Load image from URL or path and send node-canvas compatible image'
  icon: 'picture-o'
  constructor: ->
    @inPorts = new noflo.InPorts
      url:
        datatype: 'string'

        catch e
          tmpFile.unlink()
          onError e
      @inFlight[url] = req
    else
      # Local image
      loadFile url

  shutdown: ->
    for url, req of @inFlight
      req.abort()
      delete @inFlight[url]
    @q = []
    @errorGroups = []
    super()

exports.getComponent = -> new CreateImage
