@mikrojs/native 0.21.1-next.20260928214050 → 0.23.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.
- package/CMakeLists.txt +21 -0
- package/dist/runtime/result/native-result.node-shim.d.ts +2 -0
- package/dist/runtime/result/native-result.node-shim.d.ts.map +1 -1
- package/dist/runtime/result/native-result.node-shim.js +57 -0
- package/dist/runtime/result/native-result.node-shim.js.map +1 -1
- package/dist/runtime/result/types.d.ts +33 -0
- package/dist/runtime/result/types.d.ts.map +1 -1
- package/include/mikrojs/app_store.h +16 -0
- package/include/mikrojs/ble_port.h +50 -0
- package/include/mikrojs/build_install.h +36 -0
- package/include/mikrojs/device_store.h +84 -0
- package/include/mikrojs/http_native.h +52 -0
- package/include/mikrojs/mikrojs.h +19 -9
- package/include/mikrojs/ota.h +75 -0
- package/include/mikrojs/ota_env.h +1 -1
- package/include/mikrojs/platform.h +35 -0
- package/include/mikrojs/private.h +13 -3
- package/include/mikrojs/utils.h +17 -7
- package/package.json +4 -4
- package/prebuilds/darwin-arm64/mikrojs.napi.node +0 -0
- package/prebuilds/linux-arm64/mikrojs.napi.node +0 -0
- package/prebuilds/linux-x64/mikrojs.napi.node +0 -0
- package/runtime/http/server-impl.ts +5 -60
- package/runtime/http/server.ts +0 -1
- package/runtime/internal.d.ts +2 -0
- package/runtime/modules.json +1 -1
- package/runtime/result/native-result.node-shim.ts +60 -0
- package/runtime/result/result.ts +1 -1
- package/runtime/result/types.ts +61 -0
- package/runtime/sys/sys.ts +1 -2
- package/runtime/sys/types.ts +5 -2
- package/src/mik_app_store.cpp +32 -0
- package/src/mik_ble.cpp +1573 -0
- package/src/mik_build_install.cpp +785 -0
- package/src/mik_config.cpp +330 -0
- package/src/mik_console.cpp +15 -24
- package/src/mik_deploy.cpp +759 -0
- package/src/mik_ota.cpp +1403 -0
- package/src/mik_ota_client_module.cpp +1142 -0
- package/src/mik_ota_env.cpp +318 -0
- package/src/mik_repl.cpp +15 -6
- package/src/mik_result.cpp +159 -0
- package/src/mik_sys.cpp +57 -52
- package/src/mik_test.cpp +1334 -0
- package/src/mik_test_supervisor.cpp +151 -0
- package/src/mik_udp.cpp +4 -1
- package/src/mik_watchdog.cpp +4 -5
- package/src/mik_wifi_client.cpp +1 -2
- package/src/mikrojs.cpp +15 -6
- package/src/modules.cpp +2 -1
- package/src/utils.cpp +1 -2
- package/runtime/test/test.ts +0 -686
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include <string.h>
|
|
3
|
+
#include <unistd.h>
|
|
4
|
+
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
#include <nanocbor/nanocbor.h>
|
|
9
|
+
|
|
10
|
+
#include "mikrojs/device_store.h"
|
|
11
|
+
#include "mikrojs/mikrojs.h"
|
|
12
|
+
#include "mikrojs/private.h"
|
|
13
|
+
|
|
14
|
+
/* ── Unified protocol config handler ────────────────────────────── */
|
|
15
|
+
|
|
16
|
+
/** Collected config entry for CBOR encoding */
|
|
17
|
+
struct config_entry_t {
|
|
18
|
+
std::string key;
|
|
19
|
+
std::string value;
|
|
20
|
+
bool secret;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Encode a single config entry into a CBOR encoder */
|
|
24
|
+
static void encode_config_entry(nanocbor_encoder_t* enc, const config_entry_t& entry) {
|
|
25
|
+
nanocbor_fmt_map(enc, 3);
|
|
26
|
+
nanocbor_put_tstr(enc, "key");
|
|
27
|
+
nanocbor_put_tstrn(enc, entry.key.c_str(), entry.key.size());
|
|
28
|
+
nanocbor_put_tstr(enc, "value");
|
|
29
|
+
/* Header only for an empty value: in the sizing pass the encoder has no
|
|
30
|
+
* buffer, and nanocbor would memcpy zero bytes to NULL. */
|
|
31
|
+
if (entry.value.empty()) {
|
|
32
|
+
nanocbor_fmt_tstr(enc, 0);
|
|
33
|
+
} else {
|
|
34
|
+
nanocbor_put_tstrn(enc, entry.value.c_str(), entry.value.size());
|
|
35
|
+
}
|
|
36
|
+
nanocbor_put_tstr(enc, "secret");
|
|
37
|
+
nanocbor_fmt_bool(enc, entry.secret);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Build CBOR array of env entries for MSG_CONFIG_ENTRIES */
|
|
41
|
+
static std::vector<uint8_t> build_config_entries_cbor() {
|
|
42
|
+
std::vector<config_entry_t> entries;
|
|
43
|
+
|
|
44
|
+
const MIKDeviceStore* store = mik__device_store();
|
|
45
|
+
if (store && store->env_each) {
|
|
46
|
+
store->env_each(
|
|
47
|
+
[](const char* key, const char* value, bool secret, void* ud) {
|
|
48
|
+
config_entry_t entry;
|
|
49
|
+
entry.key = key;
|
|
50
|
+
entry.secret = secret;
|
|
51
|
+
/* Secret values never leave the device. */
|
|
52
|
+
if (!secret && value) entry.value = value;
|
|
53
|
+
static_cast<std::vector<config_entry_t>*>(ud)->push_back(std::move(entry));
|
|
54
|
+
},
|
|
55
|
+
&entries);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Two-pass CBOR encode */
|
|
59
|
+
nanocbor_encoder_t enc;
|
|
60
|
+
nanocbor_encoder_init(&enc, nullptr, 0);
|
|
61
|
+
nanocbor_fmt_array(&enc, entries.size());
|
|
62
|
+
for (const auto& e : entries) {
|
|
63
|
+
encode_config_entry(&enc, e);
|
|
64
|
+
}
|
|
65
|
+
size_t needed = nanocbor_encoded_len(&enc);
|
|
66
|
+
|
|
67
|
+
std::vector<uint8_t> buf(needed);
|
|
68
|
+
nanocbor_encoder_init(&enc, buf.data(), needed);
|
|
69
|
+
nanocbor_fmt_array(&enc, entries.size());
|
|
70
|
+
for (const auto& e : entries) {
|
|
71
|
+
encode_config_entry(&enc, e);
|
|
72
|
+
}
|
|
73
|
+
return buf;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
bool MIK_HandleConfigCommand(MIKReplTransport* transport, uint8_t cmd_type, uint32_t payload_len) {
|
|
77
|
+
const MIKDeviceStore* store = mik__device_store();
|
|
78
|
+
if (!store) {
|
|
79
|
+
mik__proto_drain(transport, payload_len);
|
|
80
|
+
mik__proto_send_err(transport, "no key store on this device");
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
/* A store may leave out the hooks it cannot back. */
|
|
84
|
+
if ((cmd_type == MIK_CMD_CONFIG_SET && !store->env_set) ||
|
|
85
|
+
(cmd_type == MIK_CMD_CONFIG_DELETE && !store->env_delete) ||
|
|
86
|
+
(cmd_type == MIK_CMD_KV_SET && !store->kv_set) ||
|
|
87
|
+
(cmd_type == MIK_CMD_KV_DELETE && !store->kv_delete)) {
|
|
88
|
+
mik__proto_drain(transport, payload_len);
|
|
89
|
+
mik__proto_send_err(transport, "not supported on this device");
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
switch (cmd_type) {
|
|
93
|
+
case MIK_CMD_CONFIG_LIST: {
|
|
94
|
+
mik__proto_drain(transport, payload_len);
|
|
95
|
+
auto cbor = build_config_entries_cbor();
|
|
96
|
+
mik__proto_send(transport, MIK_MSG_CONFIG_ENTRIES, cbor.data(), cbor.size());
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
case MIK_CMD_CONFIG_SET: {
|
|
101
|
+
/* Payload: u8 flags | u16le key_len | key | u16le val_len | value */
|
|
102
|
+
if (payload_len < 3) {
|
|
103
|
+
mik__proto_drain(transport, payload_len);
|
|
104
|
+
mik__proto_send_err(transport, "config header too short");
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
uint8_t flags;
|
|
108
|
+
if (!mik__proto_read_exact(transport, &flags, 1)) return false;
|
|
109
|
+
|
|
110
|
+
uint8_t kl[2];
|
|
111
|
+
if (!mik__proto_read_exact(transport, kl, 2)) return false;
|
|
112
|
+
uint16_t key_len = kl[0] | (kl[1] << 8);
|
|
113
|
+
|
|
114
|
+
char key[64];
|
|
115
|
+
if (key_len >= sizeof(key) || (uint32_t)key_len + 3 > payload_len) {
|
|
116
|
+
mik__proto_drain(transport, payload_len - 3);
|
|
117
|
+
mik__proto_send_err(transport, "key too long");
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (!mik__proto_read_exact(transport, key, key_len)) return false;
|
|
121
|
+
key[key_len] = '\0';
|
|
122
|
+
uint32_t consumed = 3 + (uint32_t)key_len;
|
|
123
|
+
|
|
124
|
+
if (consumed + 2 > payload_len) {
|
|
125
|
+
mik__proto_drain(transport, payload_len - consumed);
|
|
126
|
+
mik__proto_send_err(transport, "config value header truncated");
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
uint8_t vl[2];
|
|
130
|
+
if (!mik__proto_read_exact(transport, vl, 2)) return false;
|
|
131
|
+
uint16_t val_len = vl[0] | (vl[1] << 8);
|
|
132
|
+
consumed += 2;
|
|
133
|
+
|
|
134
|
+
char value[512];
|
|
135
|
+
if (val_len >= sizeof(value) || consumed + (uint32_t)val_len > payload_len) {
|
|
136
|
+
mik__proto_drain(transport, payload_len - consumed);
|
|
137
|
+
mik__proto_send_err(transport, "value too long");
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (!mik__proto_read_exact(transport, value, val_len)) return false;
|
|
141
|
+
value[val_len] = '\0';
|
|
142
|
+
consumed += val_len;
|
|
143
|
+
if (payload_len > consumed) mik__proto_drain(transport, payload_len - consumed);
|
|
144
|
+
|
|
145
|
+
if (key_len > 15) {
|
|
146
|
+
mik__proto_send_err(transport, "key exceeds NVS 15-char limit");
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
bool changed = false;
|
|
151
|
+
if (store->env_set(key, value, flags & MIK_ENV_FLAG_SECRET, &changed)) {
|
|
152
|
+
uint8_t byte = changed ? 1 : 0;
|
|
153
|
+
mik__proto_send(transport, MIK_MSG_OK, &byte, 1);
|
|
154
|
+
} else {
|
|
155
|
+
mik__proto_send_err(transport, "env write failed");
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
case MIK_CMD_CONFIG_DELETE: {
|
|
161
|
+
/* Payload: u16le key_len | key */
|
|
162
|
+
if (payload_len < 2) {
|
|
163
|
+
mik__proto_drain(transport, payload_len);
|
|
164
|
+
mik__proto_send_err(transport, "config header too short");
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
uint8_t kl[2];
|
|
168
|
+
if (!mik__proto_read_exact(transport, kl, 2)) return false;
|
|
169
|
+
uint16_t key_len = kl[0] | (kl[1] << 8);
|
|
170
|
+
|
|
171
|
+
char key[64];
|
|
172
|
+
if (key_len >= sizeof(key) || (uint32_t)key_len + 2 > payload_len) {
|
|
173
|
+
mik__proto_drain(transport, payload_len - 2);
|
|
174
|
+
mik__proto_send_err(transport, "key too long");
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
if (!mik__proto_read_exact(transport, key, key_len)) return false;
|
|
178
|
+
key[key_len] = '\0';
|
|
179
|
+
uint32_t consumed = 2 + (uint32_t)key_len;
|
|
180
|
+
if (payload_len > consumed) mik__proto_drain(transport, payload_len - consumed);
|
|
181
|
+
|
|
182
|
+
uint8_t byte = store->env_delete(key) ? 1 : 0;
|
|
183
|
+
mik__proto_send(transport, MIK_MSG_OK, &byte, 1);
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
case MIK_CMD_KV_SET: {
|
|
188
|
+
/* Payload: u8 ns | u16le key_len | key | u16le val_len | value.
|
|
189
|
+
* ns selects the namespace (0 = mik.kv, 1 = mik.sys). The value is
|
|
190
|
+
* stored as a CBOR text-string blob, matching what `mikro/kv/nvs`
|
|
191
|
+
* writes, so JS reads it back as a plain string. */
|
|
192
|
+
if (payload_len < 3) {
|
|
193
|
+
mik__proto_drain(transport, payload_len);
|
|
194
|
+
mik__proto_send_err(transport, "kv header too short");
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
uint8_t ns;
|
|
198
|
+
if (!mik__proto_read_exact(transport, &ns, 1)) return false;
|
|
199
|
+
if (ns > 1) {
|
|
200
|
+
mik__proto_drain(transport, payload_len - 1);
|
|
201
|
+
mik__proto_send_err(transport, "unknown kv namespace");
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
uint8_t kl[2];
|
|
206
|
+
if (!mik__proto_read_exact(transport, kl, 2)) return false;
|
|
207
|
+
uint16_t key_len = kl[0] | (kl[1] << 8);
|
|
208
|
+
|
|
209
|
+
char key[64];
|
|
210
|
+
if (key_len >= sizeof(key) || (uint32_t)key_len + 3 > payload_len) {
|
|
211
|
+
mik__proto_drain(transport, payload_len - 3);
|
|
212
|
+
mik__proto_send_err(transport, "key too long");
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
if (!mik__proto_read_exact(transport, key, key_len)) return false;
|
|
216
|
+
key[key_len] = '\0';
|
|
217
|
+
uint32_t consumed = 3 + (uint32_t)key_len;
|
|
218
|
+
|
|
219
|
+
if (consumed + 2 > payload_len) {
|
|
220
|
+
mik__proto_drain(transport, payload_len - consumed);
|
|
221
|
+
mik__proto_send_err(transport, "kv value header truncated");
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
uint8_t vl[2];
|
|
225
|
+
if (!mik__proto_read_exact(transport, vl, 2)) return false;
|
|
226
|
+
uint16_t val_len = vl[0] | (vl[1] << 8);
|
|
227
|
+
consumed += 2;
|
|
228
|
+
|
|
229
|
+
/* Sized to carry a 4 KiB config document plus its {version, doc}
|
|
230
|
+
* envelope (a config seed is the largest value this path sees);
|
|
231
|
+
* mirrored as KV_VALUE_MAX_BYTES in the CLI/sim protocol — keep
|
|
232
|
+
* the two in sync. Heap, not stack: the value and its CBOR blob
|
|
233
|
+
* together would not fit a task stack. */
|
|
234
|
+
constexpr uint32_t kValueMax = 4608;
|
|
235
|
+
if (val_len >= kValueMax || consumed + (uint32_t)val_len > payload_len) {
|
|
236
|
+
mik__proto_drain(transport, payload_len - consumed);
|
|
237
|
+
mik__proto_send_err(transport, "value too long");
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
char* value = (char*)malloc((size_t)val_len + 1);
|
|
241
|
+
uint8_t* blob = (uint8_t*)malloc((size_t)val_len + 8);
|
|
242
|
+
if (value == NULL || blob == NULL) {
|
|
243
|
+
free(value);
|
|
244
|
+
free(blob);
|
|
245
|
+
mik__proto_drain(transport, payload_len - consumed);
|
|
246
|
+
mik__proto_send_err(transport, "out of memory");
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
if (!mik__proto_read_exact(transport, value, val_len)) {
|
|
250
|
+
free(value);
|
|
251
|
+
free(blob);
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
value[val_len] = '\0';
|
|
255
|
+
consumed += val_len;
|
|
256
|
+
if (payload_len > consumed) mik__proto_drain(transport, payload_len - consumed);
|
|
257
|
+
|
|
258
|
+
if (key_len == 0 || key_len > 15) {
|
|
259
|
+
free(value);
|
|
260
|
+
free(blob);
|
|
261
|
+
mik__proto_send_err(transport, "key exceeds NVS 15-char limit");
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
nanocbor_encoder_t enc;
|
|
266
|
+
nanocbor_encoder_init(&enc, blob, (size_t)val_len + 8);
|
|
267
|
+
if (nanocbor_put_tstrn(&enc, value, val_len) < 0) {
|
|
268
|
+
free(value);
|
|
269
|
+
free(blob);
|
|
270
|
+
mik__proto_send_err(transport, "cbor encode failed");
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
size_t blob_len = nanocbor_encoded_len(&enc);
|
|
274
|
+
|
|
275
|
+
bool ok = store->kv_set(ns == 1 ? "mik.sys" : "mik.kv", key, blob, blob_len);
|
|
276
|
+
free(value);
|
|
277
|
+
free(blob);
|
|
278
|
+
if (ok) {
|
|
279
|
+
mik__proto_send_ok(transport);
|
|
280
|
+
} else {
|
|
281
|
+
mik__proto_send_err(transport, "kv write failed");
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
case MIK_CMD_KV_DELETE: {
|
|
287
|
+
/* Payload: u8 ns | u16le key_len | key */
|
|
288
|
+
if (payload_len < 3) {
|
|
289
|
+
mik__proto_drain(transport, payload_len);
|
|
290
|
+
mik__proto_send_err(transport, "kv header too short");
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
uint8_t ns;
|
|
294
|
+
if (!mik__proto_read_exact(transport, &ns, 1)) return false;
|
|
295
|
+
if (ns > 1) {
|
|
296
|
+
mik__proto_drain(transport, payload_len - 1);
|
|
297
|
+
mik__proto_send_err(transport, "unknown kv namespace");
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
uint8_t kl[2];
|
|
302
|
+
if (!mik__proto_read_exact(transport, kl, 2)) return false;
|
|
303
|
+
uint16_t key_len = kl[0] | (kl[1] << 8);
|
|
304
|
+
|
|
305
|
+
char key[64];
|
|
306
|
+
if (key_len >= sizeof(key) || (uint32_t)key_len + 3 > payload_len) {
|
|
307
|
+
mik__proto_drain(transport, payload_len - 3);
|
|
308
|
+
mik__proto_send_err(transport, "key too long");
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
if (!mik__proto_read_exact(transport, key, key_len)) return false;
|
|
312
|
+
key[key_len] = '\0';
|
|
313
|
+
uint32_t consumed = 3 + (uint32_t)key_len;
|
|
314
|
+
if (payload_len > consumed) mik__proto_drain(transport, payload_len - consumed);
|
|
315
|
+
|
|
316
|
+
int existed = store->kv_delete(ns == 1 ? "mik.sys" : "mik.kv", key);
|
|
317
|
+
if (existed < 0) {
|
|
318
|
+
mik__proto_send_err(transport, "kv delete failed");
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
uint8_t byte = existed ? 1 : 0;
|
|
322
|
+
mik__proto_send(transport, MIK_MSG_OK, &byte, 1);
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
default:
|
|
327
|
+
mik__proto_drain(transport, payload_len);
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
}
|
package/src/mik_console.cpp
CHANGED
|
@@ -331,37 +331,28 @@ static void mik__append_error_head(JSContext* ctx, JSValue exc, const char* inde
|
|
|
331
331
|
JS_FreeValue(ctx, stack_val);
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
/*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* time it is reported and skip it afterwards. Keying on object identity is
|
|
340
|
-
* exact and time-independent; a recycled address belongs to a fresh object
|
|
341
|
-
* with no marker, so distinct errors are never suppressed. Primitive
|
|
342
|
-
* rejections (e.g. a null OOM rejection) can't hold a marker and are always
|
|
343
|
-
* reported. Returns true if it reported, false if it was a duplicate. */
|
|
334
|
+
/* One error can reach here more than once, e.g. `p.then(a); p.then(b)` on a
|
|
335
|
+
* rejected `p` leaves two unhandled promises with one reason. The first report
|
|
336
|
+
* marks the error object and later ones are skipped. Primitives, proxies (their
|
|
337
|
+
* traps would see the marker) and non-extensible objects always report.
|
|
338
|
+
* Returns false for a skipped duplicate. */
|
|
344
339
|
bool mik__report_uncaught(JSContext* ctx, JSValue exc, bool in_promise) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* codes (no C++ throw), so under OOM we just report without
|
|
355
|
-
* dedup rather than abort. */
|
|
356
|
-
JS_DefinePropertyValue(ctx, exc, marker, JS_TRUE, 0);
|
|
357
|
-
JS_FreeAtom(ctx, marker);
|
|
340
|
+
MIKRuntime* mik_rt = MIK_GetRuntime(ctx);
|
|
341
|
+
JSAtom marker = mik_rt ? mik_rt->reported_atom : JS_ATOM_NULL;
|
|
342
|
+
if (marker != JS_ATOM_NULL && JS_IsObject(exc) && !JS_IsProxy(exc)) {
|
|
343
|
+
if (JS_GetOwnProperty(ctx, nullptr, exc, marker) > 0) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
/* Best-effort: on failure, report without dedup. */
|
|
347
|
+
if (JS_DefinePropertyValue(ctx, exc, marker, JS_TRUE, 0) < 0) {
|
|
348
|
+
JS_FreeValue(ctx, JS_GetException(ctx));
|
|
358
349
|
}
|
|
359
350
|
}
|
|
360
351
|
|
|
361
352
|
/* A blocking-watchdog timeout reaches here either through mik_dump_error
|
|
362
353
|
* (which already reported it; this is then a no-op) or as an unhandled
|
|
363
354
|
* rejection when the interrupted turn was a module evaluation. */
|
|
364
|
-
mik__watchdog_report_blocking(
|
|
355
|
+
mik__watchdog_report_blocking(mik_rt);
|
|
365
356
|
|
|
366
357
|
/* Fixed-size stack buffer so this function never allocates from the
|
|
367
358
|
* C++ heap. Previously we used std::string + mik_inspect here; both
|