Closed jacobcoro closed 1 year ago
Describe the bug I'm getting an error when reconnecting and calling new WebrtcProvider() on a page refresh or after a disconnect.
new WebrtcProvider()
To Reproduce Steps to reproduce the behavior:
const provider = new WebrtcProvider(name, doc, { password, signaling: servers, awareness, });
Then call provider.disconnect() or provider.destroy(), or just try connecting again with the same code and params as above.
provider.disconnect()
provider.destroy()
Error: A Yjs Doc connected to room "#room-name" already exists
Expected behavior A new provider can be created and sync to the existing room without error. Should return the provider.
Environment Information
Sorry not sure why sourcemaps aren't working, but I've found where it originates:
// src/y-webrtc.js const openRoom = (doc, provider, name, key) => { // there must only be one room if (rooms.has(name)) { throw error.create(`A Yjs Doc connected to room "${name}" already exists!`) } const room = new Room(doc, provider, name, key) rooms.set(name, /** @type {Room} */ (room)) return room }
Sorry. I realized I new WebRtcrRovider was getting called twice elsewhere in the code!
new WebRtcrRovider
Describe the bug I'm getting an error when reconnecting and calling
new WebrtcProvider()
on a page refresh or after a disconnect.To Reproduce Steps to reproduce the behavior:
Then call
provider.disconnect()
orprovider.destroy()
, or just try connecting again with the same code and params as above.Error: A Yjs Doc connected to room "#room-name" already exists
Expected behavior A new provider can be created and sync to the existing room without error. Should return the provider.
Environment Information
Sorry not sure why sourcemaps aren't working, but I've found where it originates: