We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef198e8 commit 7ea928dCopy full SHA for 7ea928d
lib/peer.ts
@@ -284,8 +284,13 @@ export class Peer extends EventEmitter<PeerEvents> implements IPeer {
284
onfulfilled?: (value: IPeer) => any,
285
onrejected?: (reason: PeerError) => any,
286
) => {
287
+ // Remove 'then' to prevent potential recursion issues
288
+ // `await` will wait for a Promise-like to resolve recursively
289
delete this.then;
- this.once("open", () => onfulfilled?.(this));
290
+
291
+ // We don’t need to worry about cleaning up listeners here
292
+ // `await`ing a Promise will make sure only one of the paths executes
293
+ this.once("open", () => onfulfilled(this));
294
this.once("error", onrejected);
295
};
296
0 commit comments