Skip to content

Commit 0071816

Browse files
fix: embedding splicer error handling (#255)
This commit fixes a regression in function generation when error handling is involved. The buggy code over-eagerly checks whether there is an error type type present on a result, when there may legitimately not be (e.g. `result<t>` in WIT). The fix is to check *only* for whether the types are returned as a pair (indicating a `result`) at all.
1 parent 21b657c commit 0071816

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

crates/spidermonkey-embedding-splicer/src/bindgen.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,7 @@ impl JsBindgen<'_> {
859859
}
860860
}
861861

862-
let err = if get_result_types(self.resolve, func.result)
863-
.is_some_and(|(_, err_ty)| err_ty.is_some())
864-
{
862+
let err = if get_result_types(self.resolve, func.result).is_some() {
865863
match abi {
866864
AbiVariant::GuestExport => ErrHandling::ThrowResultErr,
867865
AbiVariant::GuestImport => ErrHandling::ResultCatchHandler,

test/cases/http-request/source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function getResult() {
3232

3333
let responseBody;
3434

35-
const incomingBody = incomingResponse.consume().val;
35+
const incomingBody = incomingResponse.consume();
3636
{
37-
const bodyStream = incomingBody.stream().val;
37+
const bodyStream = incomingBody.stream();
3838
// const bodyStreamPollable = bodyStream.subscribe();
3939
const buf = bodyStream.blockingRead(500n);
4040
// TODO: actual streaming

test/cases/http-server/source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
export const incomingHandler = {
1010
handle(incomingRequest, responseOutparam) {
1111
const outgoingResponse = new OutgoingResponse(new Fields());
12-
let outgoingBody = outgoingResponse.body().val;
12+
let outgoingBody = outgoingResponse.body();
1313
{
14-
let outputStream = outgoingBody.write().val;
14+
let outputStream = outgoingBody.write();
1515
outputStream.blockingWriteAndFlush(
1616
new Uint8Array(new TextEncoder().encode('Hello world!')),
1717
);

0 commit comments

Comments
 (0)