@threadedstack/wmd-web 0.1.31 → 0.1.32

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/RELEASE.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wmd-web",
3
3
  "version": "0.5.1",
4
- "commit": "37ec746fa8d64cf397418bc0bfb25b3d410d65c6",
4
+ "commit": "2411aec3acce27ade7841999fd09ef0b6427e8ab",
5
5
  "previous": null,
6
6
  "decisions": [
7
7
  "D-388",
@@ -79,16 +79,16 @@
79
79
  "bytes": 1567615
80
80
  },
81
81
  "Image": {
82
- "sha256": "259ac3fbdcf92d768d5dc6335aa64817c03dfdfbe9a9cc1ac1616db89c4493b7",
82
+ "sha256": "daa4dc90fe59ceda984ba97342f0abab0a45e3ba1a14d361d142234347f5a9e4",
83
83
  "bytes": 39049224
84
84
  },
85
85
  "Image-4k": {
86
- "sha256": "938d7e67ac77538344432117109edae801fafe47af133003b013ba4faeacf1a3",
86
+ "sha256": "284de4fdb2b7a25f4ecabd03f03aaa56c1d22f99082f6c5c2db2fb0b7c5a6c36",
87
87
  "bytes": 38828040
88
88
  },
89
89
  "initramfs.cpio.gz": {
90
- "sha256": "bc842852b22c2914123e3b331a17b8c444f2c12b3d76f4e7fd800862a0277a5b",
91
- "bytes": 4715414
90
+ "sha256": "cef3a42510e38748c181c56165ad8b30520ec29fdb82f5822fdef0de3f3e5d02",
91
+ "bytes": 4715393
92
92
  },
93
93
  "features": {
94
94
  "sha256": "02693b8b6c099e10fdb7a092394102ee92971ce1e39d0d6e5327ff8be1d0ee74",
@@ -157,10 +157,10 @@
157
157
  "export-page/index.html": "f5450c89e63601bbbbffef421f03491b231d1f143070012c1c5315d4b0059f43",
158
158
  "export-page/run.css": "b57adf1e76553549c1f89ff157b7973409dedc21889cd3932948cd05b51adc6f",
159
159
  "export-page/run.js": "717636a632a40469106ddf1383e198eaac5d83651b5866d0699ec04b82462b7f",
160
- "guest/arm64/Image": "259ac3fbdcf92d768d5dc6335aa64817c03dfdfbe9a9cc1ac1616db89c4493b7",
161
- "guest/arm64/Image-4k": "938d7e67ac77538344432117109edae801fafe47af133003b013ba4faeacf1a3",
160
+ "guest/arm64/Image": "daa4dc90fe59ceda984ba97342f0abab0a45e3ba1a14d361d142234347f5a9e4",
161
+ "guest/arm64/Image-4k": "284de4fdb2b7a25f4ecabd03f03aaa56c1d22f99082f6c5c2db2fb0b7c5a6c36",
162
162
  "guest/arm64/features": "02693b8b6c099e10fdb7a092394102ee92971ce1e39d0d6e5327ff8be1d0ee74",
163
- "guest/arm64/initramfs.cpio.gz": "bc842852b22c2914123e3b331a17b8c444f2c12b3d76f4e7fd800862a0277a5b",
163
+ "guest/arm64/initramfs.cpio.gz": "cef3a42510e38748c181c56165ad8b30520ec29fdb82f5822fdef0de3f3e5d02",
164
164
  "guest/arm64/vm.wasm": "1553b50b591cc579d2ce24e79c3fd72360db34a8a337c108e25e515a5eb920b6",
165
165
  "package.json": "7d43c05047d0a3ea56b4a7709f48a60de32e15c3bdf328d55435c46637981b40",
166
166
  "src/base.js": "982f8e46dbb727ec542a494ebdb884ccd19a31ff4e091425b2d1fc01b0d4754a",
@@ -178,6 +178,7 @@
178
178
  "src/edge/bridge.js": "722c1ac6ad76d385839cbf039f4d5bdd4341d2cecd22bc7caa30285721235b5f",
179
179
  "src/edge/codes.js": "1bb32c060d4a960a2e3b384d9ff8583329861de6e2b515b0d901b503f8b8a4a7",
180
180
  "src/edge/ctl.js": "3bd44f94326aa2cf44d7ea9e284432d04f2f8c769762583f803485ba279b9f9c",
181
+ "src/edge/error-kind.js": "5ca61086a9c8b5233e5cbba3c53166545ca394981428329c27803eaf60ebf285",
181
182
  "src/edge/frame.html": "64b608f5c0f6fbc58ed5adc64137c00982503fe96a0e3876b66c5e35b206c380",
182
183
  "src/edge/frame.js": "c4cd2e2c98d0ca573cf1e29f6c71efe4e337861449b98b8c8666d881fab44b66",
183
184
  "src/edge/fs-route.js": "2e901b1c15e93a57f0696c5e46a99f87df6bd6c5e1c24cdad3c69bfba2fee281",
@@ -192,7 +193,7 @@
192
193
  "src/edge/own/fs-bridge.js": "f39dad977f44c49a4030d8f1c315bfbaa99f64d4f06a71f1904600d7eccdd778",
193
194
  "src/edge/own/fs-own-route.js": "17cbe30c7c855def21018f96b971e44914e28d9d23f713b17c991c2f0e6ddb3b",
194
195
  "src/edge/own/guest-spawner.js": "57c33f5924428f04782d1ddd4f3341631a853ef0538464082da9927d706d04a5",
195
- "src/edge/own/hub.js": "c149328a938a00d3f5e7cacbb397c7f8a2fae43f6c162899fe18dccf69cd172d",
196
+ "src/edge/own/hub.js": "753c72c446a24f6548cc2c2a88c37e6228b2922b2443b67ded945bdb6ddc6bbe",
196
197
  "src/edge/own/loader.js": "a386c8823b16a630401608e7eca4c0c056e7636d99f43d14eea7656c2df8f47f",
197
198
  "src/edge/own/memcap.js": "cb1806f8a4174d58a34546457ac7539ad39d44c6b009744b957c2f885ddef55a",
198
199
  "src/edge/own/payload-size.js": "357127fb08c2001a9d3a68ca768b9c816e385f9a61981198457b65ef7658a75e",
@@ -200,10 +201,10 @@
200
201
  "src/edge/own/procfs.js": "93d0657740fc73e484429964a0111cabb0462c1cd06f1efb6fbb93054d204e00",
201
202
  "src/edge/own/serdes-codec.js": "18db7b1b2108a2f38c71bc0bda4f6a0a38734c43943297ed0544d4dba21e8652",
202
203
  "src/edge/own/service-receiver.js": "bfaf0b3ac544b68f8d39c2c53cc85acb53b603f7d5e28d3a4a3f96df1a436a34",
203
- "src/edge/own/shim-post.js": "11e9703ccd8732a11ce9bcbc8736bd13fa8bde8a9f4ca4f9d445be1eb0413ee7",
204
+ "src/edge/own/shim-post.js": "e64e362f72c3d93ea158c6509c6e5a5fe73cfdb9e507b39213712534d4d164a3",
204
205
  "src/edge/own/stack-fix.js": "6a0be64a7159404d433e6984861d43b763c3ae60c364b24e17f08a607c330402",
205
206
  "src/edge/own/stdio-pipe.js": "9d79d6e6a74cd2923c696da2bf2b24f7a1ac7eeb16c6f311d44143201ba3201a",
206
- "src/edge/own/v8-serdes.js": "8dbd49d6e0e631b1aa8685dc094acd5fe62c2d9703bcd5884300d641957fe0cd",
207
+ "src/edge/own/v8-serdes.js": "629d5658414d2e953e3a3bebb47a607bd29f957c150c303a667c6536e59467c6",
207
208
  "src/edge/own/wasm-counters.js": "3fd28d5aca05f3a1e8a682f45bab5a0a4eb855b7d5780a5cbb047674f29de8d3",
208
209
  "src/edge/own/worker.js": "03d3781f75599efa2beb1a8c107c54d2de49400d3b450b18c7d40891e7d7bcac",
209
210
  "src/edge/page.js": "52d0a07ef58aa7cc3445c8d20645791cdabedde3ba8ad9fc87ef6d8a078d96c1",
@@ -216,11 +217,11 @@
216
217
  "src/edge/sdk/relay.js": "355194b640cd7f1c11d1cc7734737bdf7bf818b47edd5e2a103c661397075693",
217
218
  "src/edge/service-host.js": "36792b1193e2b7ce3324b6559d9e00da2a8b09520672528f8b6c9a326ac71b71",
218
219
  "src/edge/service-port.js": "c926fb968193ae6ef123bda94782327e6e831a51636859e6cca77bb610c691c5",
219
- "src/edge/shim.js": "6e2045d6ea9af09fcc82297ffa4c1ed3f1f19d9680a38d427ea6a0ec4e37d5c7",
220
+ "src/edge/shim.js": "ad61b2b705bf49ddcc6f77001b2f16e19aa99852f4c19b2a4b43a0fc296c5d51",
220
221
  "src/edge/site.js": "ff63be7c751678b773fd03e79e551e6fe6e85caa0444b6413b7bb940b8316979",
221
222
  "src/edge/spawn-guard.js": "666cc6cca0628f3c07093f08da277a1d6291eebb91c19abebf0d422f6197e401",
222
223
  "src/edge/tz.js": "4d4f4fd90febcae2b75abeb9c0704dd01a422a0339703137844c8ed3d7330000",
223
- "src/edge/worker.js": "7c13b7095f4dc7c44d19c590b62bb6beb460ecdd561475e4595ee974517cf95e",
224
+ "src/edge/worker.js": "76b51575cd3af088c4e69c6528f7bb43f0ff37f7e409e6da2664baa5a66ad739",
224
225
  "src/edge/workers.js": "44973877448172aafb3bb9274ca114801be60918f53758bf81f3b268ad100552",
225
226
  "src/fs/9p/codec.js": "69711eb4ebc84eff39256138169fe18f5a5066d6cd9e4ff2daf61c65380d7ef7",
226
227
  "src/fs/9p/server.js": "da0ba00ebb5522161bb0ef7cd94bfc9616e342bf865633dfef0ba5bc67627d7a",
@@ -236,8 +237,8 @@
236
237
  "src/host/base-file.js": "edb47c1eeb6b1cec627fa5894512185336b15d3f5db96a7151a8a57b34b4a2e8",
237
238
  "src/host/base-io.js": "cdd049875dce9f1417f28b27efa2c6f494cbe2a49851249150d0c1ec871a8b59",
238
239
  "src/host/boot-events.js": "a6567c889fa1e95ad7e917107a2593f03d14cc921827616368b3417de96faad2",
239
- "src/host/chan-service.js": "129cb6786da7330259c10b4c2f1b7adc7b39843d0d1d4c3faa1b65caaa23e59b",
240
- "src/host/chan-services.js": "ac29f3cf06ab546613604d12c574ef83c94ddae51dd7f3dfc7bcbbfc551de70c",
240
+ "src/host/chan-service.js": "da34324ede7ab2cb51769ef487808de1f42ecbee468035c112fc45a0a87e2ec2",
241
+ "src/host/chan-services.js": "aab7a60789da260b16549d5f0895e539cce0d086c066afa033d2b5840186ded4",
241
242
  "src/host/chan.js": "bb9e76890b0efeee7cfbd8481b9fb4620b3b184459d96d62ff68ddcdc8a46f83",
242
243
  "src/host/ckpt-file.js": "da7938fa640a062e77bdfb59caad5b3b1fcbf6150e3220de3be23f253f4c4497",
243
244
  "src/host/ckpt-io.js": "3fbe74f0254c597f10d088c85e8ba72725502d86ae4dd8c6d2bf0821a93c873f",
@@ -249,7 +250,7 @@
249
250
  "src/host/disk-map.js": "3d7e0d7d488ce25fc6a0e4dc0a9b1c8fc2af96bac1c03491a1d30be392af268b",
250
251
  "src/host/disk-worker.js": "6e82bfeb4aa3f8b02bd7cb2de7427def26114e016f6b05196c8485d7fc8315ee",
251
252
  "src/host/disk.js": "e941e62cc2d9a83582d53c80c09c5f0f682508f77390237bedff4051c489b2cd",
252
- "src/host/edge-go.js": "7efe26f87487dc481ad7b3a754cd301d99f55f46ae2f07390c7d3b948535bf89",
253
+ "src/host/edge-go.js": "5c325ef6876de0c75d6fca338fefa94da3d83b8a550077cf38b91e3365c37152",
253
254
  "src/host/edge-host.js": "463db51d4ea96ce4540b47acccfe0f0eb702c504dbe79f9b3404641a9def6f63",
254
255
  "src/host/errno.js": "26021d85962084be2c43c98fb3accafc2a8f11fbf3c8a5b8d484bd6a088ae4db",
255
256
  "src/host/fs.js": "d6753f74db35b7b01baa8709fc7fdcdfc8d638dfe42f454b0a833b22111e8f4a",
@@ -271,7 +272,7 @@
271
272
  "src/host/threads.js": "952381940e7f43114867e9a9714528f2f20c8064b6b0f2018ab075128dc601be",
272
273
  "src/host/wasi.js": "fbafa239b8fb4083f7e8c910b1adab38901e8e7cffd247284a9abb2847eaf4bd",
273
274
  "src/host/wmd-imports.js": "3a00562f7c9c7787ab3841b14dde5d903a78f43ed19c43a2f5e31fd8a14c09d2",
274
- "src/host/yamux.js": "d8bb8333069569a59f00440e73780942c462cbb4dd161812dfba1354b6cd08d6",
275
+ "src/host/yamux.js": "b8a9c1756af13356b380b869ecf796c009f8ed57151ed1c251bd9a4e4ae015f9",
275
276
  "src/image-files.js": "19f90a7d3c8accae5093e53bb85fe7e158ac1dd18866283722171eccb1d7e37a",
276
277
  "src/net/dhcp-dns.js": "fdfa7c7d5cbbb4a8774b7dee195bf2df22a0c3fe8f20ac9694b24485fa8f25d5",
277
278
  "src/net/net-worker.js": "0a2ce998f69807e386ded7ff1bee53687a1d59ed76d7ef46e2eb6f958b14ad38",
package/guest/arm64/Image CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/guest/arm64/Image
3
3
  size: 39049224 bytes
4
- sha256: 259ac3fbdcf92d768d5dc6335aa64817c03dfdfbe9a9cc1ac1616db89c4493b7
4
+ sha256: daa4dc90fe59ceda984ba97342f0abab0a45e3ba1a14d361d142234347f5a9e4
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/guest/arm64/Image-4k
3
3
  size: 38828040 bytes
4
- sha256: 938d7e67ac77538344432117109edae801fafe47af133003b013ba4faeacf1a3
4
+ sha256: 284de4fdb2b7a25f4ecabd03f03aaa56c1d22f99082f6c5c2db2fb0b7c5a6c36
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadedstack/wmd-web",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/threadedstack/wmd-releases",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "description": "Browser host for wmd's guest vm.wasm (Web Workers + shared memory + WASI preview1)",
11
11
  "wmd": {
12
- "tag": "v0.1.31",
13
- "commit": "37ec746fa8d64cf397418bc0bfb25b3d410d65c6",
12
+ "tag": "v0.1.32",
13
+ "commit": "2411aec3acce27ade7841999fd09ef0b6427e8ab",
14
14
  "web": "0.5.1"
15
15
  },
16
16
  "type": "module",
@@ -0,0 +1,4 @@
1
+ // X5 fix 11 (F-M): which errors of a start say that the runtime's own files did not load. The page remembers such a start (bridge.js: counted as a
2
+ // runtime failure, the next nodes go to the guest until the retry time) and says what failed. An error while load() runs is one; so is an error that
3
+ // carries `runtimeFiles` (src/edge/own/hub.js: the runtime's wasm was not there or did not compile; it comes in start(), after load()).
4
+ export const errorKindOf = (e, loading) => (loading || (e && e.runtimeFiles === true) ? 'runtime' : undefined)
@@ -108,7 +108,15 @@ export class OwnRuntime {
108
108
 
109
109
  async #boot() {
110
110
  const { wasmUrl, workerUrl, stack } = this.#opts
111
- this.#module = this.#opts.module || (await WebAssembly.compileStreaming(fetch(wasmUrl)))
111
+ try {
112
+ this.#module = this.#opts.module || (await WebAssembly.compileStreaming(fetch(wasmUrl)))
113
+ } catch (e) {
114
+ // fix 11 (F-M): a runtime wasm that is not there (a 404 is the browser's own bare TypeError) or does not compile is a runtime that did not load: the
115
+ // page counts it and remembers it (src/edge/worker.js, bridge.js) as it does for a file that does not match HASHES.txt
116
+ const err = new Error(`the runtime's wasm did not load (${wasmUrl}): ${String((e && e.message) || e)}`)
117
+ err.runtimeFiles = true
118
+ throw err
119
+ }
112
120
  this.#main = this.#create(workerUrl, { type: 'module', name: 'wmd-own-main' })
113
121
  this.#main.addEventListener('message', (e) => this.#fromWorker(e.data))
114
122
  this.#main.addEventListener('error', (e) => this.#fatal(new Error('runtime main worker: ' + (e.message || 'error'))))
@@ -65,7 +65,8 @@ export function ownShimPost(process, realGlobal, g, utcClock, utcNames = [], req
65
65
  const ignored = new Set(sigIgnored || [])
66
66
  const later = (f) => (typeof g.setImmediate === 'function' ? g.setImmediate(f) : setTimeout(f, 0))
67
67
  process.kill = function kill(pid, sig) {
68
- const mine = pid === process.pid || pid === 0 || pid === '0' || String(pid) === String(process.pid)
68
+ // fix 11 (F-E): -pid is the program's own group (it leads it in the frame), so it is the program too; any other negative pid goes to the native call
69
+ const mine = pid === process.pid || pid === 0 || pid === '0' || String(pid) === String(process.pid) || String(pid) === '-' + process.pid
69
70
  if (!mine) return nativeKill.apply(process, arguments)
70
71
  if (sig === 0 || sig === '0') return true
71
72
  const num = sig === undefined ? 15 : typeof sig === 'number' ? sig : byName[sig]
@@ -34,6 +34,47 @@ const VIEW_TAGS = [
34
34
  const VERSION = 15
35
35
  const FLAG_BITS = [['g', 1], ['i', 2], ['m', 4], ['y', 8], ['u', 16], ['s', 32], ['l', 64], ['d', 128], ['v', 256]]
36
36
  const MAX_INDEX = 4294967294
37
+ // the flags V8 writes after a view (version 14 and later): bit 0, the view's length follows its buffer; bit 1, its buffer is resizable
38
+ const VIEW_LENGTH_TRACKING = 1
39
+ const VIEW_BACKED_BY_RAB = 2
40
+ const VERSION_ERROR = 'Unable to deserialize cloned data due to invalid or unsupported version.'
41
+ const MIN_VERSION = 13 // node's v8.Deserializer refuses an older wire format (V8's API: no legacy format without SetSupportsLegacyWireFormat)
42
+
43
+ // -1 for a view that is out of bounds (its buffer shrank under it): a DataView's byteLength throws then, and so does any method of a typed array
44
+ const viewByteLength = (v) => {
45
+ try {
46
+ if (typeof v.at === 'function') v.at(0)
47
+ return v.byteLength
48
+ } catch {
49
+ return -1
50
+ }
51
+ }
52
+ // Whether a view on a resizable buffer follows the buffer's length (V8 writes the flag and a byte length of 0 for it). A view cannot be
53
+ // asked; the buffer is grown by one element and put back, and a view that grew follows it. A buffer already at its largest size is
54
+ // shrunk by one element instead (its last bytes are put back). Nothing outside this call can see it: it runs to its end before any other code.
55
+ const tracksLength = (v, ab) => {
56
+ const before = viewByteLength(v)
57
+ if (before < 0) return false
58
+ const size = ab.byteLength
59
+ const per = v.BYTES_PER_ELEMENT || 1
60
+ try {
61
+ if (size + per <= ab.maxByteLength) {
62
+ ab.resize(size + per)
63
+ const grew = viewByteLength(v) !== before
64
+ ab.resize(size)
65
+ return grew
66
+ }
67
+ if (size - per >= v.byteOffset) {
68
+ const kept = new Uint8Array(ab).slice(size - per)
69
+ ab.resize(size - per)
70
+ const after = viewByteLength(v)
71
+ ab.resize(size)
72
+ new Uint8Array(ab).set(kept, size - per)
73
+ return before >= per && after === before - per // a view of no elements cannot be told from a fixed one of none: it stays fixed
74
+ }
75
+ } catch {}
76
+ return false
77
+ }
37
78
 
38
79
  const own = (o, k) => Object.getOwnPropertyDescriptor(o, k)
39
80
  const tagOf = (o) => Object.prototype.toString.call(o)
@@ -436,6 +477,16 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
436
477
  const k = kind >= 0 ? kind : VIEW_TAGS.findIndex(([name]) => name !== 'DataView' && tagOf(v) === `[object ${name}]`)
437
478
  const idx = k >= 0 ? k : tagOf(v) === '[object DataView]' ? VIEW_TAGS.length - 1 : -1
438
479
  if (idx < 0) return this._fail(`${this._describe(v)} could not be cloned.`)
480
+ // a view on a resizable buffer says so, and says when it follows the buffer's length (then its byte length is 0, as V8 writes it)
481
+ let flags = 0
482
+ let length = v.byteLength
483
+ if (v.buffer.resizable === true) {
484
+ flags = VIEW_BACKED_BY_RAB
485
+ if (tracksLength(v, v.buffer)) {
486
+ flags |= VIEW_LENGTH_TRACKING
487
+ length = 0
488
+ }
489
+ }
439
490
  // the buffer goes first (it is written when it has no id yet), then the view takes its id
440
491
  if (!this._ids.has(v.buffer)) {
441
492
  this._ids.set(v.buffer, this._next++)
@@ -448,8 +499,8 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
448
499
  w.byte(T.VIEW)
449
500
  w.byte(VIEW_TAGS[idx][1])
450
501
  w.varint(v.byteOffset)
451
- w.varint(v.byteLength)
452
- return w.varint(0)
502
+ w.varint(length)
503
+ return w.varint(flags)
453
504
  }
454
505
 
455
506
  _error(e) {
@@ -496,12 +547,20 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
496
547
  this._transfer = new Map()
497
548
  this._dv = new DataView(this.bytes.buffer, this.bytes.byteOffset, this.bytes.byteLength)
498
549
  }
550
+ // V8's ReadHeader and the API's check: no version tag, a cut version, a version above 15 or below 13 give the version error
499
551
  readHeader() {
552
+ let version = 0
500
553
  if (this.bytes[this.offset] === 0xff) {
501
554
  this.offset++
502
- this._version = this._varint()
503
- if (this._version > VERSION) throw new Error('Unable to deserialize cloned data due to invalid or unsupported version.')
504
- } else throw new Error('Unable to deserialize cloned data due to invalid or unsupported version.')
555
+ try {
556
+ version = this._varint32()
557
+ } catch (e) {
558
+ throw e && e.__serdes ? new Error(VERSION_ERROR) : e
559
+ }
560
+ this._version = version
561
+ if (version > VERSION) throw new Error(VERSION_ERROR)
562
+ }
563
+ if (version < MIN_VERSION) throw new Error(VERSION_ERROR)
505
564
  return true
506
565
  }
507
566
  readValue() {
@@ -518,25 +577,39 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
518
577
  transferArrayBuffer(id, ab) {
519
578
  this._transfer.set(Number(id) >>> 0, ab)
520
579
  }
580
+ // the reads a program makes itself fail with node's texts (src/node_serdes.cc), not with the reader's own
581
+ _called(text, f) {
582
+ try {
583
+ return f()
584
+ } catch (e) {
585
+ throw e && e.__serdes ? new Error(text) : e
586
+ }
587
+ }
521
588
  readUint32() {
522
- return this._varint()
589
+ return this._called('ReadUint32() failed', () => this._varint32())
523
590
  }
524
591
  readUint64() {
525
- const big = this._varintBig()
526
- return [Number(big >> 32n) >>> 0, Number(big & 0xffffffffn)]
592
+ return this._called('ReadUint64() failed', () => {
593
+ const big = this._varintBig()
594
+ return [Number(big >> 32n) >>> 0, Number(big & 0xffffffffn)]
595
+ })
527
596
  }
528
597
  readDouble() {
529
- this._need(8)
530
- const n = this._dv.getFloat64(this.offset, true)
531
- this.offset += 8
532
- return n
598
+ return this._called('ReadDouble() failed', () => {
599
+ this._need(8)
600
+ const n = this._dv.getFloat64(this.offset, true)
601
+ this.offset += 8
602
+ return n
603
+ })
533
604
  }
534
605
  _readRawBytes(length) {
535
606
  const n = Number(length) >>> 0
536
- this._need(n)
537
- const at = this.offset
538
- this.offset += n
539
- return at
607
+ return this._called('ReadRawBytes() failed', () => {
608
+ this._need(n)
609
+ const at = this.offset
610
+ this.offset += n
611
+ return at
612
+ })
540
613
  }
541
614
 
542
615
  _bad() {
@@ -551,6 +624,18 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
551
624
  this._need(1)
552
625
  return this.bytes[this.offset++]
553
626
  }
627
+ // V8's ReadVarint<uint32_t>: five bytes at most, the high bits dropped; a sixth byte must exist but is not consumed
628
+ _varint32() {
629
+ let n = 0
630
+ for (let i = 0; ; i++) {
631
+ this._need(1)
632
+ const b = this.bytes[this.offset]
633
+ if (i === 5) return n >>> 0
634
+ this.offset++
635
+ n |= (b & 0x7f) << (7 * i)
636
+ if (!(b & 0x80)) return n >>> 0
637
+ }
638
+ }
554
639
  _varint() {
555
640
  let n = 0
556
641
  let scale = 1
@@ -619,10 +704,13 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
619
704
  const bits = this._varint()
620
705
  const neg = bits & 1
621
706
  const n = Math.floor(bits / 2)
622
- if (n % 8) throw this._bad()
707
+ if (neg && n === 0) throw this._bad() // V8 has no negative zero
623
708
  this._need(n)
709
+ // V8 takes any length (the last digit is padded): the bytes of a part digit are the highest
710
+ const tail = n % 8
624
711
  let v = 0n
625
- for (let i = n / 8 - 1; i >= 0; i--) v = (v << 64n) | this._dv.getBigUint64(this.offset + i * 8, true)
712
+ for (let i = n - 1; i >= n - tail; i--) v = (v << 8n) | BigInt(this.bytes[this.offset + i])
713
+ for (let i = (n - tail) / 8 - 1; i >= 0; i--) v = (v << 64n) | this._dv.getBigUint64(this.offset + i * 8, true)
626
714
  this.offset += n
627
715
  return neg ? -v : v
628
716
  }
@@ -631,6 +719,7 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
631
719
  return o
632
720
  }
633
721
  _setKey(o, k, v) {
722
+ if (Object.hasOwn(o, k)) throw this._bad() // V8 refuses a key the object already has
634
723
  if (k === '__proto__') Object.defineProperty(o, k, { value: v, writable: true, enumerable: true, configurable: true })
635
724
  else o[k] = v
636
725
  }
@@ -653,6 +742,9 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
653
742
  this._skipPadding()
654
743
  const t = this._byte()
655
744
  switch (t) {
745
+ case T.VERIFY:
746
+ this._varint32() // V8 reads the object count and ignores it
747
+ return this._read()
656
748
  case T.UNDEF:
657
749
  return undefined
658
750
  case T.NULL:
@@ -693,7 +785,7 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
693
785
  }
694
786
  case T.DENSE: {
695
787
  const len = this._varint()
696
- if (len > this.bytes.length) throw this._bad()
788
+ if (len > this.bytes.length - this.offset) throw this._bad() // V8: each element takes a byte at least
697
789
  const a = this._add(new Array(len))
698
790
  for (let i = 0; i < len; i++) {
699
791
  if (this._peek() === T.HOLE) {
@@ -738,10 +830,12 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
738
830
  return this._add(Object(this._readString()))
739
831
  case T.REGEXP: {
740
832
  const source = this._readString()
741
- const bits = this._varint()
833
+ const bits = this._varint32()
834
+ // V8: only the nine flag bits, not the linear one (64), and not both u and v
835
+ if (bits & ~0x1bf || (bits & 16 && bits & 256)) throw this._bad()
742
836
  let flags = ''
743
837
  for (const [c, b] of FLAG_BITS) if (bits & b) flags += c
744
- return this._add(new RegExp(source, flags.replace('l', '')))
838
+ return this._add(new RegExp(source, flags)) // a pattern that does not compile throws the engine's SyntaxError, as V8's reader does
745
839
  }
746
840
  case T.MAP: {
747
841
  const m = this._add(new Map())
@@ -814,12 +908,20 @@ export function makeSerdesBinding({ bufferOf = null } = {}) {
814
908
  if (k < 0) throw this._bad()
815
909
  const offset = this._varint()
816
910
  const length = this._varint()
817
- if (this._version >= 14) this._varint()
911
+ const flags = this._version >= 14 ? this._varint() >>> 0 : 0
912
+ const tracking = (flags & VIEW_LENGTH_TRACKING) !== 0
913
+ const rab = (flags & VIEW_BACKED_BY_RAB) !== 0
914
+ // V8's ValidateJSArrayBufferViewFlags: the flags and the buffer must agree on whether it is resizable
915
+ if ((tracking || rab) && ab.resizable !== true) throw this._bad()
916
+ if (ab.resizable === true && !rab) throw this._bad()
818
917
  const C = globalThis[VIEW_TAGS[k][0]]
819
918
  if (typeof C !== 'function') throw this._bad()
919
+ const per = C === DataView ? 1 : C.BYTES_PER_ELEMENT || 1
920
+ if (offset % per || length % per) throw this._bad() // V8: the offset and the length are whole elements
820
921
  let v
821
922
  try {
822
- v = C === DataView ? new DataView(ab, offset, length) : new C(ab, offset, length / (C.BYTES_PER_ELEMENT || 1))
923
+ if (C === DataView) v = tracking ? new DataView(ab, offset) : new DataView(ab, offset, length)
924
+ else v = tracking ? new C(ab, offset) : new C(ab, offset, length / (C.BYTES_PER_ELEMENT || 1))
823
925
  } catch {
824
926
  throw this._bad()
825
927
  }
package/src/edge/shim.js CHANGED
@@ -128,11 +128,11 @@ export function withoutSymlinkOverride(links) {
128
128
  const SIG_TABLE_FROM = " const SIG_NAMES = { 1: 'SIGHUP', 2: 'SIGINT', 3: 'SIGQUIT', 15: 'SIGTERM' };"
129
129
  export const SIG_NAMES_LINUX = {
130
130
  1: 'SIGHUP', 2: 'SIGINT', 3: 'SIGQUIT', 4: 'SIGILL', 5: 'SIGTRAP', 6: 'SIGABRT', 7: 'SIGBUS', 8: 'SIGFPE', 10: 'SIGUSR1', 11: 'SIGSEGV', 12: 'SIGUSR2',
131
- 13: 'SIGPIPE', 14: 'SIGALRM', 15: 'SIGTERM', 16: 'SIGSTKFLT', 17: 'SIGCHLD', 18: 'SIGCONT', 20: 'SIGTSTP', 21: 'SIGTTIN', 22: 'SIGTTOU', 23: 'SIGURG',
131
+ 13: 'SIGPIPE', 14: 'SIGALRM', 15: 'SIGTERM', 16: 'SIGSTKFLT', 17: 'SIGCHLD', 18: 'SIGCONT', 19: 'SIGSTOP', 20: 'SIGTSTP', 21: 'SIGTTIN', 22: 'SIGTTOU', 23: 'SIGURG',
132
132
  24: 'SIGXCPU', 25: 'SIGXFSZ', 26: 'SIGVTALRM', 27: 'SIGPROF', 28: 'SIGWINCH', 29: 'SIGIO', 30: 'SIGPWR', 31: 'SIGSYS',
133
133
  }
134
134
  /** The signals whose default action leaves the program running. */
135
- export const SIG_IGNORED_LINUX = [10, 13, 17, 18, 20, 21, 22, 23, 28]
135
+ export const SIG_IGNORED_LINUX = [10, 13, 17, 18, 19, 20, 21, 22, 23, 28]
136
136
  const SIG_TABLE_TO = ` const SIG_NAMES = ${JSON.stringify(SIG_NAMES_LINUX)};\n const SIG_IGNORED = new Set(${JSON.stringify(SIG_IGNORED_LINUX)});`
137
137
  const SIG_EMIT_FROM = ` if (process.listenerCount(name) > 0) {
138
138
  process.emit(name, name);
@@ -8,6 +8,7 @@
8
8
  // env: {}, args: [], cwd, timeoutMs, parallelism, spawn, stdin, stream, linux}
9
9
  // Messages out: {type: 'log', text}, {type: 'step', name: 'ready'}, {type: 'out', kind, bytes}, {type: 'done', ...}
10
10
  import { RT_DEFAULT, loadAdapter } from './runtime.js'
11
+ import { errorKindOf } from './error-kind.js'
11
12
  import { installWasmCounters } from './own/wasm-counters.js'
12
13
  import { SPAWN_EXIT, markScanner, newSpawnMark } from './spawn-guard.js'
13
14
 
@@ -113,7 +114,8 @@ onmessage = async ({ data: { cfg, ports, in: inp } }) => {
113
114
  // no adapter.teardown(): the runtime's Workers end when the frame terminates this one (fix9, see done)
114
115
  } catch (e) {
115
116
  res.error = String((e && e.stack) || e)
116
- if (loading) res.errorKind = 'runtime'
117
+ const kind = errorKindOf(e, loading) // fix 11 (F-M): the runtime's wasm that is missing is found in start(), after load()
118
+ if (kind) res.errorKind = kind
117
119
  }
118
120
  done(res)
119
121
  }
@@ -363,6 +363,7 @@ async function loadWithin(load, limitMs, what) {
363
363
  * stay, and the folder with them: with the page switch edge=1 (X5) the image's node runs through the same stub.
364
364
  */
365
365
  function noTwin(fsx, tools, why) {
366
+ twinOffWhy = why // fix 11 (F-N): no GoEdge exists to count it; the stats carry it as gowasmOff
366
367
  const file = 'bundle/config/config.json'
367
368
  try {
368
369
  const spec = JSON.parse(new TextDecoder().decode(fsx.readFile(file)))
@@ -396,8 +397,9 @@ function bindGoPort(p) {
396
397
  }
397
398
  }
398
399
 
400
+ let twinOffWhy = null // fix 11 (F-N): why the twin's module did not load (noTwin), for the stats
399
401
  let lastStats = ''
400
- const withSpin = s => ({ ...s, spin: { ...spin, curUs: spinCur }, ...(edgeHost ? { edge: { ...edgeHost.stats, fallbackWhy: { ...edgeHost.stats.fallbackWhy }, look: { ...edgeSvc.stats }, route: edge ? (({ runs, ports, released, handles, requests, bad, children, ring, wait, waitByMethod, serdes }) => ({ runs, ports, released, handles, requests, bad, children, ring, wait, waitByMethod, serdes }))(edge.stats()) : null } } : {}) })
402
+ const withSpin = s => ({ ...s, spin: { ...spin, curUs: spinCur }, ...(twinOffWhy ? { gowasmOff: twinOffWhy } : {}), ...(edgeHost ? { edge: { ...edgeHost.stats, fallbackWhy: { ...edgeHost.stats.fallbackWhy }, look: { ...edgeSvc.stats }, route: edge ? (({ runs, ports, released, handles, requests, bad, children, ring, wait, waitByMethod, serdes }) => ({ runs, ports, released, handles, requests, bad, children, ring, wait, waitByMethod, serdes }))(edge.stats()) : null } } : {}) })
401
403
  let lastStatsAt = 0
402
404
  function maybePostStats() {
403
405
  const t = nowMs()
@@ -236,12 +236,18 @@ export function edgeTaker(go, node) {
236
236
  const pieces = kept
237
237
  kept = null
238
238
  stream.onData = stream.onFin = stream.onClose = null
239
- to(stream)
240
- for (const u8 of pieces) {
241
- if (stream.closed) return
242
- stream.onData?.(u8)
239
+ try {
240
+ to(stream)
241
+ for (const u8 of pieces) {
242
+ if (stream.closed) return
243
+ stream.onData?.(u8)
244
+ }
245
+ if (fin && !stream.closed) stream.onFin?.()
246
+ } catch {
247
+ // a taker that throws: the stream is reset, the error is counted, and the exception stays out of the yamux feed (fix 11, F-B)
248
+ stream.session.stats.takerErrors++
249
+ stream.abort('edge: the taker failed')
243
250
  }
244
- if (fin && !stream.closed) stream.onFin?.()
245
251
  }
246
252
  stream.onData = u8 => {
247
253
  const nl = u8.indexOf(10)
@@ -295,6 +295,7 @@ export class GoEdge {
295
295
  this.failures = 0 // failures of the twin since its last good compile
296
296
  this.ruleSeen = new Set() // the rules (see #rule) that have raised their event on this machine
297
297
  this.ruleWhy = {} // rule -> the reason text of the first time
298
+ this.offWhy = null // fix 11 (F-N): the reason it is off, once it is
298
299
  this.off = false // turned off for the machine (FAIL_LIMIT failures in a row, or a module that is not the one tools.json names)
299
300
  this.lastBeat = 0
300
301
  this.watch = null // the timer of the watchdog, there while a run is out or the Worker has not said ready
@@ -319,7 +320,7 @@ export class GoEdge {
319
320
  }
320
321
 
321
322
  snapshot() {
322
- return { ...this.stats, reasons: { ...this.stats.reasons }, rules: { ...this.stats.rules }, ruleWhy: { ...this.ruleWhy }, ready: this.ready, off: this.off, failures: this.failures, queued: this.queue.length, open: this.open.size }
323
+ return { ...this.stats, reasons: { ...this.stats.reasons }, rules: { ...this.stats.rules }, ruleWhy: { ...this.ruleWhy }, ready: this.ready, off: this.off, offWhy: this.offWhy, failures: this.failures, queued: this.queue.length, open: this.open.size }
323
324
  }
324
325
 
325
326
  /** How many stubs wait for an answer now (for the report; a checkpoint no longer waits for them, see checkpointBlock). */
@@ -1117,6 +1118,7 @@ export class GoEdge {
1117
1118
  #turnOff(why) {
1118
1119
  if (this.off) return
1119
1120
  this.off = true
1121
+ this.offWhy = why // fix 11 (F-N): the counters say why, not only the event
1120
1122
  this.ready = false
1121
1123
  this.dead = true
1122
1124
  this.sent.clear()
package/src/host/yamux.js CHANGED
@@ -198,7 +198,7 @@ export class YamuxClient {
198
198
  this.lastPingAt = now()
199
199
  this.pingId = 0
200
200
  this.pings = new Map() // id -> sent at
201
- this.stats = { pingsSent: 0, pingsAnswered: 0, pingTimeouts: 0, pingRttMs: [], guestPings: 0, refused: 0, accepted: 0, discarded: 0, opened: 0, bytesIn: 0, bytesOut: 0 }
201
+ this.stats = { pingsSent: 0, pingsAnswered: 0, pingTimeouts: 0, pingRttMs: [], guestPings: 0, refused: 0, accepted: 0, discarded: 0, opened: 0, bytesIn: 0, bytesOut: 0, takerErrors: 0 }
202
202
  }
203
203
 
204
204
  _send(u8) {
@@ -324,7 +324,15 @@ export class YamuxClient {
324
324
  this.streams.set(id, st)
325
325
  this.stats.accepted++
326
326
  this._send(yamuxHeader(T_WINDOW, F_ACK, id, 0))
327
- if (this.accept(st) === false) {
327
+ let taken
328
+ try {
329
+ taken = this.accept(st)
330
+ } catch {
331
+ // a taker that throws is a refusal: the stream gets a reset, the error is counted and the feed goes on (fix 11, F-B)
332
+ this.stats.takerErrors++
333
+ taken = false
334
+ }
335
+ if (taken === false) {
328
336
  this.stats.refused++
329
337
  st.abort('refused')
330
338
  }
package/wmdpack.wasm CHANGED
Binary file