Skip to content

Currently awareness state only removed at the end of a browser, not Node, session #7

@WebCoder49

Description

@WebCoder49

For your information: this is an inconsistency in the code I noticed, and I have not run the code to work this out. Nevertheless, I think and hope the report will be useful (and I'm not misinterpreting the code); I will keep it brief.

Checklist

Describe the bug
The code adds a handler to remove its awareness state on the browser window beforeunload event, but not when the Node.js process is ended. According to the last bullet point in the first list in its README y-dat supports "both node and the browser" so I would expect both handlers. Here is the current browser-only code:

y-dat/src/y-dat.js

Lines 258 to 262 in 745d25f

if (typeof window !== 'undefined') {
window.addEventListener('beforeunload', () => {
awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload')
})
}

To Reproduce
N/A

Expected behavior
The code should probably add an 'exit' handler to process if it exists, to close the connection at the end when run in Node.js, like in y-webrtc:

https://github.com/yjs/y-webrtc/blob/c411f1d7223b68f3c6fc9c5901a19819a17db667/src/y-webrtc.js#L374-L379

Screenshots
N/A

Environment Information
N/A

Additional context
N/A

  • I'm a sponsor 💖
  • This issue is a blocker for my project.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions