Skip to content

Commit 4ca7393

Browse files
authored
fix: should check if namespace exist before trim (#24)
1 parent e85b438 commit 4ca7393

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/y-socket-io/y-socket-io.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,17 @@ export class YSocketIO {
536536
} else {
537537
await this.client.store.persistDoc(namespace, 'index', doc)
538538
}
539-
await this.client.trimRoomStream(namespace, 'index')
539+
540+
/**
541+
* there's a possibility where the namespace is deleted after the
542+
* persist promise resolved, so we have to check if the room still
543+
* exist.
544+
* @see cleanupNamespace
545+
* @see cleanupNamespaceImpl
546+
*/
547+
if (this.namespaceMap.has(namespace)) {
548+
await this.client.trimRoomStream(namespace, 'index')
549+
}
540550
} catch (e) {
541551
console.error(e)
542552
} finally {

0 commit comments

Comments
 (0)