diff --git a/cli/ops/dispatch_json.rs b/cli/ops/dispatch_json.rs index a575aedb3e1d42..a3c6ab7a76e251 100644 --- a/cli/ops/dispatch_json.rs +++ b/cli/ops/dispatch_json.rs @@ -37,7 +37,19 @@ fn serialize_result( Ok(v) => json!({ "ok": v, "promiseId": promise_id }), Err(err) => json!({ "err": json_err(err), "promiseId": promise_id }), }; - let vec = serde_json::to_vec(&value).unwrap(); + let mut vec = serde_json::to_vec(&value).unwrap(); + + debug!("JSON response pre-align, len={}", vec.len()); + let modulo = vec.len() % 4; + + if modulo != 0 { + let n = 4 - modulo; + for _ in 0..n { + vec.push(0); + } + } + + debug!("JSON response post-align, len={}", vec.len()); vec.into_boxed_slice() } diff --git a/core/shared_queue.rs b/core/shared_queue.rs index 11c8e21271c062..20138fa5643ff1 100644 --- a/core/shared_queue.rs +++ b/core/shared_queue.rs @@ -162,6 +162,14 @@ impl SharedQueue { pub fn push(&mut self, op_id: OpId, record: &[u8]) -> bool { let off = self.head(); let end = off + record.len(); + debug!( + "rust:shared_queue:pre-push: op={}, off={}, end={}, len={}", + op_id, + off, + end, + record.len() + ); + assert_eq!(record.len() % 4, 0); let index = self.num_records(); if end > self.bytes.len() || index >= MAX_RECORDS { debug!("WARNING the sharedQueue overflowed"); diff --git a/js/dispatch_json.ts b/js/dispatch_json.ts index e8c97616454ce4..fc02131e5e632d 100644 --- a/js/dispatch_json.ts +++ b/js/dispatch_json.ts @@ -30,7 +30,10 @@ function nextPromiseId(): number { } function decode(ui8: Uint8Array): JsonResponse { - const s = new TextDecoder().decode(ui8); + let s = new TextDecoder().decode(ui8); + // TODO: this is make-shift solution + const closingBracket = s.lastIndexOf("}"); + s = s.slice(0, closingBracket + 1); return JSON.parse(s) as JsonResponse; } diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py index e3674d0954420a..2394ad160fd544 100755 --- a/tools/http_benchmark.py +++ b/tools/http_benchmark.py @@ -28,7 +28,7 @@ def get_addr(port=None): def deno_tcp(deno_exe): addr = get_addr() deno_cmd = [deno_exe, "run", "--allow-net", "tools/deno_tcp.ts", addr] - print "http_benchmark testing DENO." + print "http_benchmark testing DENO tcp." return run(deno_cmd, addr) @@ -38,7 +38,7 @@ def deno_tcp_current_thread(deno_exe): deno_exe, "run", "--current-thread", "--allow-net", "tools/deno_tcp.ts", addr ] - print "http_benchmark testing DENO." + print "http_benchmark testing DENO tcp (single-thread)." return run(deno_cmd, addr)