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

client.destroy() does not clean up everything #1605

Closed
lacker opened this issue Mar 28, 2019 · 1 comment
Closed

client.destroy() does not clean up everything #1605

lacker opened this issue Mar 28, 2019 · 1 comment

Comments

@lacker
Copy link

@lacker lacker commented Mar 28, 2019

Using:
webtorrent@0.103.0
Ubuntu 18.04.2 LTS
Node v8.10.0

This code creates a client, download one torrent, then attempts to shut down the client cleanly:

const WebTorrent = require("webtorrent-hybrid");

const SAMPLESITE =
  "magnet:?xt=urn:btih:e60f82343019bd711c5c731b46e118b0f2b2ecc6&dn=samplesite&tr=ws%3A%2F%2Flocalhost%3A4444&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com";

let client = new WebTorrent();
let info = SAMPLESITE;
console.log("adding", info);
client.add(info, torrent => {
  for (let file of torrent.files) {
    console.log("file:", file.name);
  }
  torrent.on("done", () => {
    console.log("downloaded", torrent.downloaded, "bytes");
    console.log("shutting down");
    client.destroy(err => {
      console.log("error:", err);
      console.log("shutdown allegedly complete");
    });
  });
});

When I run this, the download succeeds, all callbacks run, and there is no error, but the node process does not close, indicating that destroy is leaving something open.

I ran it from within wtfnode to debug, and it shows a bunch of open timer handles from the simple-peer library:

- Timers:
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
  - (5000 ~ 5 s) (anonymous) @ /home/lacker/js/node_modules/simple-peer/index.js:544
@lacker

This comment has been minimized.

Copy link
Author

@lacker lacker commented Apr 4, 2019

I debugged this some more. Although it doesn't clean up everything immediately, the only remaining handles are timers that will eventually go off and leave nothing open. So it does clean up within 5 seconds, which I'm guessing is "working sufficiently well as intended". I'll close this issue

@lacker lacker closed this Apr 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.