*Change userData logic to throw error if set, but try to always set it

This commit is contained in:
Derrick Hammer 2023-04-06 22:53:15 -04:00
parent e0178e41ed
commit 98bb74d8b1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 1 deletions

View File

@ -280,7 +280,11 @@ class Channel {
module.exports = class Protomux { module.exports = class Protomux {
constructor(stream, { alloc, slave = false } = {}) { constructor(stream, { alloc, slave = false } = {}) {
if (stream.userData === null) stream.userData = this; if (stream.userData) {
throw new Error("Mux already set for this stream");
}
stream.userData = this;
this.isProtomux = true; this.isProtomux = true;
this.stream = stream; this.stream = stream;