Skip to content

Commit

Permalink
Fix: Callbacks didn't clean up properly after .destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
therealPaulPlay committed Jan 31, 2025
1 parent 17f428d commit 83bf0aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playpeerjs",
"version": "1.2.2",
"version": "1.2.3",
"description": "WebRTC-based wrapper for creating robust peer-2-peer multiplayer systems with ease.",
"type": "module",
"main": "dist/playpeer.js",
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ export default class PlayPeer {
this.#triggerEvent("destroy");
}

// Clear intervals
clearInterval(this.#heartbeatSendInterval);

// Resets
this.#peer = undefined;
this.#storage = {};
Expand All @@ -597,10 +600,7 @@ export default class PlayPeer {
this.#hostConnectionsIdArray = [];
this.#initialized = false;
this.#maxSize = undefined;

// Clear intervals
clearInterval(this.#heartbeatSendInterval);
this.#triggerEvent("status", "Resetted internal data.");
this.#callbacks.clear();
} catch (error) {
console.error(ERROR_PREFIX + "Error during cleanup:", error);
this.#triggerEvent("error", "Error during cleanup: " + error);
Expand Down

0 comments on commit 83bf0aa

Please sign in to comment.