Skip to content

Somehow prevent or discourage people from creating a huge number of independent TorClients

There's an antipattern in our API: it's possible and easy to create a huge number of separate TorClient instances that do not share internal state, which all try to bootstrap independently. This needlessly wastes resources.

It's possible that the confusion here is exacerbated by the fact that we would prefer people to create a large number of TorClient instances that do share internal state, by creating one instance and Cloneing it.

Possible solutions include:

  • Removing our "shared state" code (see #611), or making it off-by-default.
  • Adding more documentation to discourage people from doing this.
  • Somehow making it harder to do in the same process in the API.
  • Creating a runtime warning if people do this.