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

BREAKING: Many fixes; all leaks fixed #762

Merged
merged 12 commits into from Apr 22, 2016
Merged

BREAKING: Many fixes; all leaks fixed #762

merged 12 commits into from Apr 22, 2016
Commits on Apr 21, 2016
  1. BREAKING: Major cleanup

    feross committed Apr 21, 2016
    ### Added
    
    - `client.listening` property to signal whether TCP server is listening
    for incoming
      connections.
    
    ### Changed
    
    - Merged `Swarm` class into `Torrent` object. Properties on
    `torrent.swarm` (like
      `torrent.swarm.wires`) now exist on `torrent` (e.g. `torrent.wires`).
    
    - `torrent.addPeer` can no longer be called before the `infoHash` event
    has been
      emitted.
    
    - Remove `torrent.on('listening')` event. Use `client.on('listening')`
    instead.
    
    - Remove support from `TCPPool` for listening on multiple ports. This
    was not used by
      WebTorrent and just added complexity. There is now a single `TCPPool`
    instance for the
      whole WebTorrent client.
    
    - Deprecate: Do not use `client.download()` anymore. Use `client.add()`
    instead.
    
    - Deprecate: Do not use `torrent.swarm` anymore. Use `torrent` instead.
    
    ### Fixed
    
    - When there is a `torrent.on('error')` listener, don't also emit
      `client.on('error')`.
    
    - Do not return existing torrent object when duplicate torrent is
    added. Fire an
      `'error'` event instead.
    
    - Memory leak of `Torrent` object caused by `RarityMap`
    
    - Memory leak of `Torrent` object caused by `TCPPool`
    
    - `client.ratio` and `torrent.ratio` are now calculated as `uploaded /
    received` instead
      of `uploaded / downloaded`.
  2. More thorough object cleanup

    feross committed Apr 21, 2016
    - Only pass `torrent.infoHash` to the Chunk Store constructor, instead
    of the `Torrent`
      instance itself, to prevent accidental memory leaks of the `Torrent`
    object by the
      store. (Open an issue if you were using other properties. They can be
    re-added.)
    
    - Non-fatal errors with a single torrent will be emitted at
    `torrent.on('error')`. You
      should listen to this event. Previously, all torrent errors were also
    emitted on
      `client.on('error')` and handling `torrent.on('error')` was optional.
    This design is
      better since now it is possible to distinguish between fatal client
    errors
      (`client.on('error')`) when the whole client becomes unusable versus
    recoverable errors
      where only a single torrent fails (`torrent.on('error')`) but the
    client can continue to
      be used. However, if there is no `torrent.on('error')` event, then
    the error will be
      forwarded to `client.on('error')`. This prevents crashing the client
    when the user
      only has a listener on the client, but it makes it impossible for
    them to determine
      a client error versus a torrent error.
    
    - Errors creating a torrent with `client.seed` are now emitted on the
    returned `torrent`
      object instead of the client (unless there is no event listeners on
      `torrent.on('error')` as previously discussed). The torrent object is
    now also destroyed
      automatically for the user, as was probably expected.
    
    - If `client.get` is passed a `Torrent` instance, it now only returns
    it if it is present
      in the client.
  3. use simple-concat

    feross committed Apr 21, 2016
  4. Fix exceptions

    feross committed Apr 21, 2016
  5. Fix one more peer leak

    feross committed Apr 21, 2016
  6. fix more bugs

    feross committed Apr 21, 2016
You can’t perform that action at this time.