@cubejs-client/ws-transport 1.0.12 → 1.0.14
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.
- package/dist/cubejs-client-ws-transport.esm.js +19 -2
- package/dist/cubejs-client-ws-transport.esm.js.map +1 -1
- package/dist/cubejs-client-ws-transport.js +21 -2
- package/dist/cubejs-client-ws-transport.js.map +1 -1
- package/dist/cubejs-client-ws-transport.umd.js +198 -48
- package/dist/cubejs-client-ws-transport.umd.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +26 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE1E;;;;;;;GAOG;AAEH,cAAM,wBAAwB;IAC5B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAEhB,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE;IAKhE,IAAI;IAIV,KAAK;IAKC,IAAI;CAGlB;AAED,KAAK,yBAAyB,GAAG;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IAEf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EA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+
"version": "1.0.14",
|
|
4
4
|
"engines": {},
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.1.2",
|
|
23
|
-
"@cubejs-client/core": "1.0.
|
|
23
|
+
"@cubejs-client/core": "1.0.14",
|
|
24
24
|
"core-js": "^3.6.5",
|
|
25
25
|
"isomorphic-ws": "^4.0.1",
|
|
26
26
|
"ws": "^7.3.1"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@babel/core": "^7.3.3",
|
|
35
35
|
"@babel/preset-env": "^7.3.1",
|
|
36
36
|
"@babel/preset-typescript": "^7.12.1",
|
|
37
|
-
"@cubejs-backend/linter": "1.0.
|
|
37
|
+
"@cubejs-backend/linter": "1.0.14",
|
|
38
38
|
"@types/ws": "^7.2.9",
|
|
39
39
|
"babel-jest": "^27",
|
|
40
40
|
"jest": "^27",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"eslintConfig": {
|
|
47
47
|
"extends": "../cubejs-linter"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5a5adc9c0f74eb768c36cb70cfce7c835ead54e9"
|
|
50
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
+
|
|
3
|
+
import type { CloseEvent, MessageEvent } from 'ws';
|
|
2
4
|
import type { ITransport, ITransportResponse } from '@cubejs-client/core';
|
|
3
5
|
|
|
4
6
|
/**
|
|
@@ -138,10 +140,10 @@ class WebSocketTransport implements ITransport<WebSocketTransportResult> {
|
|
|
138
140
|
ws.sendMessage({ authorization: this.authorization });
|
|
139
141
|
};
|
|
140
142
|
|
|
141
|
-
ws.onmessage = (event:
|
|
143
|
+
ws.onmessage = (event: MessageEvent) => {
|
|
142
144
|
ws.lastMessageTimestamp = new Date();
|
|
143
145
|
|
|
144
|
-
const message: any = JSON.parse(event.data);
|
|
146
|
+
const message: any = JSON.parse(event.data.toString());
|
|
145
147
|
if (message.handshake) {
|
|
146
148
|
ws.reconcile();
|
|
147
149
|
ws.reconcileTimer = setInterval(() => {
|
|
@@ -160,16 +162,37 @@ class WebSocketTransport implements ITransport<WebSocketTransportResult> {
|
|
|
160
162
|
ws.sendQueue();
|
|
161
163
|
};
|
|
162
164
|
|
|
163
|
-
ws.onclose = () => {
|
|
165
|
+
ws.onclose = (event: CloseEvent) => {
|
|
164
166
|
if (ws && ws.readyState !== WebSocket.CLOSED && ws.readyState !== WebSocket.CLOSING) {
|
|
165
167
|
ws.close();
|
|
166
168
|
}
|
|
169
|
+
|
|
167
170
|
if (ws.reconcileTimer) {
|
|
168
171
|
clearInterval(ws.reconcileTimer);
|
|
169
172
|
ws.reconcileTimer = null;
|
|
170
173
|
}
|
|
174
|
+
|
|
171
175
|
if (this.ws === ws) {
|
|
172
176
|
this.ws = null;
|
|
177
|
+
|
|
178
|
+
// Close code 1009: Message Too Big. Server rejects messages exceeding maxPayload
|
|
179
|
+
// without decoding. Retrying would cause an infinite loop, so we notify subscribers
|
|
180
|
+
// and clear subscriptions instead.
|
|
181
|
+
if (event?.code === 1009) {
|
|
182
|
+
const error = new WebSocketTransportResult({
|
|
183
|
+
status: 413,
|
|
184
|
+
message: { error: event?.reason || 'WebSocket message too big' }
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
Object.values(this.messageIdToSubscription).forEach(sub => {
|
|
188
|
+
sub.callback(error);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
this.messageIdToSubscription = {};
|
|
192
|
+
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
173
196
|
if (Object.keys(this.messageIdToSubscription).length) {
|
|
174
197
|
this.initSocket();
|
|
175
198
|
}
|