@lowdefy/client 6.0.0 → 6.1.0
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.
|
@@ -12,26 +12,34 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import {
|
|
15
|
+
*/ import { getDevError } from '@lowdefy/engine';
|
|
16
|
+
import { UserError } from '@lowdefy/errors';
|
|
16
17
|
import { serializer } from '@lowdefy/helpers';
|
|
17
18
|
function createHandleError(lowdefy) {
|
|
18
19
|
const loggedErrors = new Set();
|
|
19
20
|
const logger = lowdefy._internal.logger;
|
|
20
21
|
function logError(error) {
|
|
21
|
-
|
|
22
|
-
lowdefy._runtimeErrorCallback?.(error);
|
|
23
|
-
}
|
|
22
|
+
lowdefy._runtimeErrorCallback?.(error);
|
|
24
23
|
logger.error(error);
|
|
25
24
|
}
|
|
26
25
|
return async function handleError(error) {
|
|
27
|
-
|
|
26
|
+
// The dev tools show the dev server's full error; every decision below stays on
|
|
27
|
+
// the error config sees. Keying on the shown message means two different dev
|
|
28
|
+
// failures of one action both display. Every server failure carries its own
|
|
29
|
+
// requestId, and prod gives them all one generic message, so the requestId in
|
|
30
|
+
// the key is what lets a later failure - and the ID support asks for - log at
|
|
31
|
+
// all; one failure reaching here twice still logs once.
|
|
32
|
+
const devError = getDevError(error);
|
|
33
|
+
const shown = devError ?? error;
|
|
34
|
+
const errorKey = `${shown.message}:${error.configKey ?? ''}:${error.requestId ?? ''}`;
|
|
28
35
|
if (loggedErrors.has(errorKey)) {
|
|
29
36
|
return;
|
|
30
37
|
}
|
|
31
38
|
loggedErrors.add(errorKey);
|
|
32
|
-
// UserError is client-only — log to browser console, never send to server
|
|
39
|
+
// UserError is client-only — log to browser console, never send to server or
|
|
40
|
+
// the error bar
|
|
33
41
|
if (error instanceof UserError) {
|
|
34
|
-
|
|
42
|
+
logger.error(shown);
|
|
35
43
|
return;
|
|
36
44
|
}
|
|
37
45
|
// Send known error types to server for logging with location resolution
|
|
@@ -41,7 +49,7 @@ function createHandleError(lowdefy) {
|
|
|
41
49
|
// but never gets a source (location resolution is skipped for it), so
|
|
42
50
|
// keying on source POSTed it back and had it logged twice.
|
|
43
51
|
if (error.handled) {
|
|
44
|
-
logError(
|
|
52
|
+
logError(shown);
|
|
45
53
|
return;
|
|
46
54
|
}
|
|
47
55
|
// Client-originated errors — send to server for logging + location resolution
|
|
@@ -70,11 +78,11 @@ function createHandleError(lowdefy) {
|
|
|
70
78
|
} catch {
|
|
71
79
|
// Server logging failed - continue with local console
|
|
72
80
|
}
|
|
73
|
-
logError(
|
|
81
|
+
logError(shown);
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
84
|
// Other errors - just log locally
|
|
77
|
-
logError(
|
|
85
|
+
logError(shown);
|
|
78
86
|
};
|
|
79
87
|
}
|
|
80
88
|
export default createHandleError;
|
package/dist/request.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import {
|
|
15
|
+
*/ import { decodeServerError } from '@lowdefy/engine';
|
|
16
|
+
import { translate } from '@lowdefy/helpers';
|
|
16
17
|
async function request({ url, method = 'GET', body }) {
|
|
17
18
|
const res = await fetch(url, {
|
|
18
19
|
method,
|
|
@@ -24,7 +25,7 @@ async function request({ url, method = 'GET', body }) {
|
|
|
24
25
|
if (!res.ok) {
|
|
25
26
|
const body = await res.json();
|
|
26
27
|
if (body?.['~e']) {
|
|
27
|
-
throw
|
|
28
|
+
throw decodeServerError(body);
|
|
28
29
|
}
|
|
29
30
|
throw new Error(body.message || translate({
|
|
30
31
|
key: 'client.requestError'
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
15
|
+
*/ import { decodeServerError } from '@lowdefy/engine';
|
|
16
|
+
const ACK_TIMEOUT_MS = 10 * 1000;
|
|
16
17
|
const IDLE_CLOSE_GRACE_MS = 5 * 1000;
|
|
17
18
|
const RECONNECT_BASE_MS = 500;
|
|
18
19
|
const RECONNECT_CAP_MS = 15 * 1000;
|
|
@@ -87,7 +88,7 @@ function createWebSocketClient(lowdefy) {
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
function handleFrame(frame) {
|
|
90
|
-
const { message, payload, requestId, websocketId } = frame;
|
|
91
|
+
const { error: errorPayload, message, payload, requestId, websocketId } = frame;
|
|
91
92
|
const subscription = subscriptions.get(websocketId);
|
|
92
93
|
switch(frame.type){
|
|
93
94
|
case 'message':
|
|
@@ -118,7 +119,9 @@ function createWebSocketClient(lowdefy) {
|
|
|
118
119
|
}
|
|
119
120
|
case 'error':
|
|
120
121
|
{
|
|
121
|
-
|
|
122
|
+
// Reply frames carry the error payload; broadcasts and frame-format
|
|
123
|
+
// errors carry only a message string.
|
|
124
|
+
const error = errorPayload ? decodeServerError(errorPayload) : new Error(message ?? 'WebSocket error.');
|
|
122
125
|
if (requestId && pendingPublishes.has(requestId)) {
|
|
123
126
|
const pending = pendingPublishes.get(requestId);
|
|
124
127
|
clearTimeout(pending.timer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ant-design/icons": "6.1.0",
|
|
37
37
|
"antd": "6.3.1",
|
|
38
|
-
"@lowdefy/block-utils": "6.
|
|
39
|
-
"@lowdefy/engine": "6.
|
|
40
|
-
"@lowdefy/errors": "6.
|
|
41
|
-
"@lowdefy/helpers": "6.
|
|
42
|
-
"@lowdefy/layout": "6.
|
|
43
|
-
"@lowdefy/logger": "6.
|
|
38
|
+
"@lowdefy/block-utils": "6.1.0",
|
|
39
|
+
"@lowdefy/engine": "6.1.0",
|
|
40
|
+
"@lowdefy/errors": "6.1.0",
|
|
41
|
+
"@lowdefy/helpers": "6.1.0",
|
|
42
|
+
"@lowdefy/layout": "6.1.0",
|
|
43
|
+
"@lowdefy/logger": "6.1.0",
|
|
44
44
|
"dayjs": "1.11.20",
|
|
45
45
|
"react": "18.2.0",
|
|
46
46
|
"react-dom": "18.2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@jest/globals": "28.1.3",
|
|
51
|
-
"@lowdefy/jest-yaml-transform": "6.
|
|
51
|
+
"@lowdefy/jest-yaml-transform": "6.1.0",
|
|
52
52
|
"@swc/cli": "0.8.1",
|
|
53
53
|
"@swc/core": "1.15.32",
|
|
54
54
|
"@swc/jest": "0.2.39",
|