feat: enable `websocket-websys` in NodeJS environments.
Description
This enables websocket-websys in NodeJS environments through the following mechanisms:
-
WebContexthas a newUnknownvariant, which is only initialized ifsetIntervalandclearIntervalare available -
dial()will panic ifWebSocketis unavailable. To circumvent any speed issues, the value is cached in an atomic and retrieved when asked multiple times.
(2) is essential, as otherwise, we try to access an object that doesn't exist; from my experience, this will make NodeJS do weird things, halting execution immediately of the whole script, returning success, and swallowing any error.
Fixes #5024
Change checklist
- [x] I have performed a self-review of my own code
- [x] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] A changelog entry has been made in the appropriate crates
(3) is a bit hard here, as far as I know we don't yet really have a test harness for both web workers and nodejs environments, is that correct?
This also fixes another bug that was present (unintentionally?) where the code would correctly detect the worker scope but then refer to the globals instead of the worker scope.
This pull request has merge conflicts. Could you please resolve them @indietyp? 🙏