@synapticon/motion-master-client 6.0.0-alpha.54 → 6.0.0-alpha.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,19 @@ export class WebSocketConnection {
48
48
  }
49
49
  this.closedByUser = false;
50
50
  this.setState('connecting');
51
- const socket = new Impl(this.url, this.protocolsOrOptions);
51
+ let socket;
52
+ try {
53
+ socket = new Impl(this.url, this.protocolsOrOptions);
54
+ }
55
+ catch (err) {
56
+ // A malformed URL (e.g. a bad host/port from stale saved settings) makes the WebSocket
57
+ // constructor throw synchronously. Report it as a failed connection and stay closed rather
58
+ // than letting it propagate and crash the caller; a bad URL won't fix itself, so there is no
59
+ // point scheduling a reconnect. The consumer observes 'closed' and can correct the endpoint.
60
+ this.setState('closed');
61
+ console.error(`WebSocketConnection: failed to open ${this.url}`, err);
62
+ return;
63
+ }
52
64
  this.socket = socket;
53
65
  socket.onopen = () => {
54
66
  this.reconnectAttempts = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapticon/motion-master-client",
3
- "version": "6.0.0-alpha.54",
3
+ "version": "6.0.0-alpha.55",
4
4
  "description": "Isomorphic TypeScript client for Motion Master: the generated HTTP API client, the WebSocket connection, and helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {