Skip to content

Commit 0f3f5b2

Browse files
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4ac2aed commit 0f3f5b2

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/hyperlight-js/src/sandbox/host_fn.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,11 @@ impl HostModule {
202202
// data is not supported — reject if blobs are present.
203203
if !blobs.is_empty() {
204204
return Err(crate::HyperlightError::Error(format!(
205-
"Function '{name}' received {} binary argument(s) but was registered \
206-
with `register` (typed JSON-only). Use `register_js` for functions \
207-
that accept Uint8Array/Buffer arguments.",
205+
concat!(
206+
"Function '{name}' received {} binary argument(s) but was registered ",
207+
"with `register` (typed JSON-only). Use `register_js` for functions ",
208+
"that accept Uint8Array/Buffer arguments."
209+
),
208210
blobs.len()
209211
)));
210212
}

src/js-host-api/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ Node.js code.
465465
Host functions natively support `Uint8Array`/`Buffer` arguments and returns.
466466
Binary data travels through a dedicated sidecar channel, keeping overhead
467467
minimal. Top-level `Buffer` arguments and returns are passed as raw bytes
468-
with no encoding. Nested Buffers inside returned objects/arrays are
469-
serialized by napi-rs's default conversion.
468+
with no encoding. Nested `Buffer`/`Uint8Array` values inside returned objects
469+
and arrays are also extracted into the binary sidecar and restored on the
470+
guest side.
470471
471472
```javascript
472473
const { SandboxBuilder } = require('@hyperlight/js-host-api');

src/js-host-api/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,9 @@ unsafe fn napi_to_json_with_buffer_extraction(
12001200
}
12011201
Ok(serde_json::Value::Object(obj))
12021202
}
1203-
// Symbols, functions, bigints, external — produce null like JSON.stringify.
1203+
// Symbols, functions, bigints, external — currently coerced to JSON null for host
1204+
// return values. Note: this intentionally differs from JSON.stringify, which e.g.
1205+
// throws on BigInt and omits certain properties instead of serializing them to null.
12041206
_ => Ok(serde_json::Value::Null),
12051207
}
12061208
}

0 commit comments

Comments
 (0)