core-3nweb-client-lib 0.43.3 → 0.43.4
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.
|
@@ -28,8 +28,11 @@ function openSocket(url, sessionId) {
|
|
|
28
28
|
const headers = {};
|
|
29
29
|
headers[request_utils_1.SESSION_ID_HEADER] = sessionId;
|
|
30
30
|
const ws = new WebSocket(url, { headers, agent: https_1.globalAgent });
|
|
31
|
-
|
|
32
|
-
const initOnError = (err) =>
|
|
31
|
+
let opening = (0, deferred_1.defer)();
|
|
32
|
+
const initOnError = (err) => {
|
|
33
|
+
opening === null || opening === void 0 ? void 0 : opening.reject((0, http_1.makeConnectionException)(url, undefined, `WebSocket connection error: ${err.message}`));
|
|
34
|
+
opening = undefined;
|
|
35
|
+
};
|
|
33
36
|
const onNonOkReply = (req, res) => {
|
|
34
37
|
const errReply = {
|
|
35
38
|
url,
|
|
@@ -37,7 +40,8 @@ function openSocket(url, sessionId) {
|
|
|
37
40
|
status: res.statusCode,
|
|
38
41
|
data: undefined
|
|
39
42
|
};
|
|
40
|
-
opening.resolve(errReply);
|
|
43
|
+
opening === null || opening === void 0 ? void 0 : opening.resolve(errReply);
|
|
44
|
+
opening = undefined;
|
|
41
45
|
};
|
|
42
46
|
ws.on('error', initOnError);
|
|
43
47
|
ws.on('unexpected-response', onNonOkReply);
|
|
@@ -48,10 +52,15 @@ function openSocket(url, sessionId) {
|
|
|
48
52
|
status: 200,
|
|
49
53
|
data: ws
|
|
50
54
|
};
|
|
51
|
-
opening.resolve(okReply);
|
|
55
|
+
opening === null || opening === void 0 ? void 0 : opening.resolve(okReply);
|
|
56
|
+
opening = undefined;
|
|
52
57
|
ws.removeListener('error', initOnError);
|
|
53
58
|
ws.removeListener('unexpected-response', onNonOkReply);
|
|
54
59
|
});
|
|
60
|
+
ws.on('error', err => {
|
|
61
|
+
// XXX we need
|
|
62
|
+
console.error(`Error in ${ws.url} connection`, err);
|
|
63
|
+
});
|
|
55
64
|
return opening.promise;
|
|
56
65
|
}
|
|
57
66
|
Object.freeze(exports);
|
|
@@ -38,15 +38,12 @@ function makeJsonCommPoint(ws) {
|
|
|
38
38
|
const observers = new generic_ipc_1.MultiObserverWrap();
|
|
39
39
|
const { heartbeat, healthyBeat, otherBeat } = makeHeartbeat(ws.url);
|
|
40
40
|
ws.on('message', data => {
|
|
41
|
-
if (typeof data !== 'string') {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
41
|
if (observers.done) {
|
|
45
42
|
return;
|
|
46
43
|
}
|
|
47
44
|
let env;
|
|
48
45
|
try {
|
|
49
|
-
env = JSON.parse(data);
|
|
46
|
+
env = JSON.parse(data.toString('utf8'));
|
|
50
47
|
}
|
|
51
48
|
catch (err) {
|
|
52
49
|
ws.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-3nweb-client-lib",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.4",
|
|
4
4
|
"description": "3NWeb client core library, embeddable into different environments",
|
|
5
5
|
"main": "build/lib-index.js",
|
|
6
6
|
"types": "build/lib-index.d.ts",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"protobufjs": "^7.0.1",
|
|
33
33
|
"punycode": "^2.1.1",
|
|
34
34
|
"rxjs": "^7.5.7",
|
|
35
|
-
"ws": "^
|
|
35
|
+
"ws": "^8.18.3",
|
|
36
36
|
"xsp-files": "^4.2.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/jasmine": "^3.9.1",
|
|
40
40
|
"@types/node": "^16.11.7",
|
|
41
|
-
"@types/ws": "^
|
|
41
|
+
"@types/ws": "^8.18.1",
|
|
42
42
|
"jasmine": "^3.9.0",
|
|
43
43
|
"protobufjs-cli": "^1.0.2",
|
|
44
44
|
"spec-3nweb-server": "^1.8.0",
|