core-3nweb-client-lib 0.41.11 → 0.41.12
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/build/core/asmail/inbox/inbox-events.js +1 -1
- package/build/core/storage/synced/remote-events.js +1 -1
- package/build/lib-client/3nstorage/storage-owner.d.ts +2 -1
- package/build/lib-client/3nstorage/storage-owner.js +2 -2
- package/build/lib-client/asmail/recipient.d.ts +2 -1
- package/build/lib-client/asmail/recipient.js +2 -2
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-common/ipc/generic-ipc.js +2 -0
- package/build/lib-common/ipc/ws-ipc.d.ts +2 -1
- package/build/lib-common/ipc/ws-ipc.js +53 -11
- package/package.json +1 -1
- package/test-data-1-1759430800070/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-10-1759430836227/util/logs/2025-10-02.log.txt +11 -0
- package/test-data-11-1759430836227/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-12-1759430839895/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-13-1759430840691/util/logs/2025-10-02.log.txt +11 -0
- package/test-data-2-1759430800073/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-3-1759430804613/util/logs/2025-10-02.log.txt +11 -0
- package/test-data-4-1759430810570/util/logs/2025-10-02.log.txt +11 -0
- package/test-data-5-1759430819813/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-6-1759430821685/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-7-1759430823627/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-8-1759430832141/util/logs/2025-10-02.log.txt +6 -0
- package/test-data-9-1759430832943/util/logs/2025-10-02.log.txt +11 -0
|
Binary file
|
|
@@ -315,6 +315,7 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
315
315
|
throw makeEventException({
|
|
316
316
|
channel: this.channel,
|
|
317
317
|
unknownEvent: true,
|
|
318
|
+
event,
|
|
318
319
|
message: `Events' channel ${event} is not found in handling subscribe`
|
|
319
320
|
});
|
|
320
321
|
}
|
|
@@ -328,6 +329,7 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
328
329
|
throw makeEventException({
|
|
329
330
|
channel: this.channel,
|
|
330
331
|
unknownEvent: true,
|
|
332
|
+
event,
|
|
331
333
|
message: `Events' channel ${event} is not found in handling unsubscribe`
|
|
332
334
|
});
|
|
333
335
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
1
2
|
import { SubscribingClient } from './generic-ipc';
|
|
2
3
|
import * as WebSocket from 'ws';
|
|
3
4
|
export { RequestEnvelope, RequestHandler, EventfulServer, makeEventfulServer, SubscribingClient } from './generic-ipc';
|
|
@@ -7,4 +8,4 @@ export interface WSException extends web3n.RuntimeException {
|
|
|
7
8
|
socketClosed?: true;
|
|
8
9
|
}
|
|
9
10
|
export declare function makeWSException(params: Partial<WSException>, flags?: Partial<WSException>): WSException;
|
|
10
|
-
export declare function makeSubscriber(ws: WebSocket, ipcChannel: string | undefined): SubscribingClient;
|
|
11
|
+
export declare function makeSubscriber(ws: WebSocket, ipcChannel: string | undefined, log: LogError): SubscribingClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017, 2025 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -32,12 +32,13 @@ const MAX_TXT_BUFFER = 64 * 1024;
|
|
|
32
32
|
* messages.
|
|
33
33
|
* @param ws
|
|
34
34
|
*/
|
|
35
|
-
function makeJsonCommPoint(ws) {
|
|
35
|
+
function makeJsonCommPoint(ws, log) {
|
|
36
36
|
const observers = new generic_ipc_1.MultiObserverWrap();
|
|
37
|
-
|
|
38
|
-
ws.on('
|
|
39
|
-
ws.on('
|
|
40
|
-
ws.on('
|
|
37
|
+
const resetTimer = makeSignalsTimeObserver(ws.url, log);
|
|
38
|
+
ws.on('message', onTxtMessage(ws, observers, resetTimer));
|
|
39
|
+
ws.on('close', onClose(observers, resetTimer));
|
|
40
|
+
ws.on('error', onError(ws, observers, resetTimer));
|
|
41
|
+
ws.on('ping', onPing(ws, resetTimer));
|
|
41
42
|
const commPoint = {
|
|
42
43
|
subscribe: obs => observers.add(obs),
|
|
43
44
|
postMessage(env) {
|
|
@@ -54,7 +55,7 @@ function makeJsonCommPoint(ws) {
|
|
|
54
55
|
* @param ws
|
|
55
56
|
* @param observers
|
|
56
57
|
*/
|
|
57
|
-
function onTxtMessage(ws, observers) {
|
|
58
|
+
function onTxtMessage(ws, observers, resetTimer) {
|
|
58
59
|
return (data) => {
|
|
59
60
|
if (typeof data !== 'string') {
|
|
60
61
|
return;
|
|
@@ -72,18 +73,21 @@ function onTxtMessage(ws, observers) {
|
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
observers.next(env);
|
|
76
|
+
resetTimer();
|
|
75
77
|
};
|
|
76
78
|
}
|
|
77
79
|
/**
|
|
78
80
|
* This generates an on-close callback for a web socket.
|
|
79
81
|
* @param observers
|
|
80
82
|
*/
|
|
81
|
-
function onClose(observers) {
|
|
83
|
+
function onClose(observers, resetTimer) {
|
|
82
84
|
return (code, reason) => {
|
|
83
85
|
if (code === 1000) {
|
|
86
|
+
resetTimer(true);
|
|
84
87
|
observers.complete();
|
|
85
88
|
}
|
|
86
89
|
else {
|
|
90
|
+
resetTimer(true, { code, reason });
|
|
87
91
|
observers.error(makeWSException({
|
|
88
92
|
socketClosed: true,
|
|
89
93
|
cause: { code, reason }
|
|
@@ -96,14 +100,52 @@ function onClose(observers) {
|
|
|
96
100
|
* @param ws
|
|
97
101
|
* @param observers
|
|
98
102
|
*/
|
|
99
|
-
function onError(ws, observers) {
|
|
103
|
+
function onError(ws, observers, closeTimer) {
|
|
100
104
|
return (err) => {
|
|
105
|
+
closeTimer(true, err);
|
|
101
106
|
observers.error(makeWSException({ cause: err }));
|
|
102
107
|
ws.close();
|
|
103
108
|
};
|
|
104
109
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
110
|
+
function onPing(ws, resetTimer) {
|
|
111
|
+
return () => {
|
|
112
|
+
resetTimer();
|
|
113
|
+
ws.pong();
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function makeSignalsTimeObserver(url, log) {
|
|
117
|
+
const serverPingSettings = 2 * 60 * 1000;
|
|
118
|
+
let lastMoment = Date.now();
|
|
119
|
+
let int = undefined;
|
|
120
|
+
function resetWait(setNew = true) {
|
|
121
|
+
lastMoment = Date.now();
|
|
122
|
+
if (int) {
|
|
123
|
+
clearInterval(int);
|
|
124
|
+
int = undefined;
|
|
125
|
+
}
|
|
126
|
+
if (setNew) {
|
|
127
|
+
int = setInterval(() => {
|
|
128
|
+
log(`Ping/data from ${url} is not observed in last ${Math.floor((Date.now() - lastMoment) / 1000)} seconds`);
|
|
129
|
+
}, serverPingSettings * 1.5).unref();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return (done, err) => {
|
|
133
|
+
if (done) {
|
|
134
|
+
if (err) {
|
|
135
|
+
log(`WebSocket to ${url} closed with error`, err);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
log(`WebSocket to ${url} closed`);
|
|
139
|
+
}
|
|
140
|
+
resetWait(false);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
resetWait();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function makeSubscriber(ws, ipcChannel, log) {
|
|
148
|
+
const comm = makeJsonCommPoint(ws, log);
|
|
107
149
|
return (0, generic_ipc_1.makeSubscribingClient)(ipcChannel, comm);
|
|
108
150
|
}
|
|
109
151
|
Object.freeze(exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
Thu Oct 02 2025 14:47:19 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
3
|
+
Core version 0.41.12
|
|
4
|
+
Log level: error.
|
|
5
|
+
[object Object]
|
|
6
|
+
WebSocket to wss://localhost:8088/asmail/retrieval/events closed with error
|
|
7
|
+
Thu Oct 02 2025 14:47:19 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
8
|
+
Core version 0.41.12
|
|
9
|
+
Log level: error.
|
|
10
|
+
[object Object]
|
|
11
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
Thu Oct 02 2025 14:47:22 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
3
|
+
Core version 0.41.12
|
|
4
|
+
Log level: error.
|
|
5
|
+
[object Object]
|
|
6
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
7
|
+
Thu Oct 02 2025 14:47:22 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
8
|
+
Core version 0.41.12
|
|
9
|
+
Log level: error.
|
|
10
|
+
[object Object]
|
|
11
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
Thu Oct 02 2025 14:46:50 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
3
|
+
Core version 0.41.12
|
|
4
|
+
Log level: error.
|
|
5
|
+
[object Object]
|
|
6
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
7
|
+
Thu Oct 02 2025 14:46:50 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
8
|
+
Core version 0.41.12
|
|
9
|
+
Log level: error.
|
|
10
|
+
[object Object]
|
|
11
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
Thu Oct 02 2025 14:46:56 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
3
|
+
Core version 0.41.12
|
|
4
|
+
Log level: error.
|
|
5
|
+
[object Object]
|
|
6
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
7
|
+
Thu Oct 02 2025 14:46:56 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
8
|
+
Core version 0.41.12
|
|
9
|
+
Log level: error.
|
|
10
|
+
[object Object]
|
|
11
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
Thu Oct 02 2025 14:47:16 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
3
|
+
Core version 0.41.12
|
|
4
|
+
Log level: error.
|
|
5
|
+
[object Object]
|
|
6
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|
|
7
|
+
Thu Oct 02 2025 14:47:16 GMT-0400 (Eastern Daylight Saving Time) ==================================
|
|
8
|
+
Core version 0.41.12
|
|
9
|
+
Log level: error.
|
|
10
|
+
[object Object]
|
|
11
|
+
WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
|