Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions crates/js-component-bindgen/src/intrinsics/p3/async_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,7 @@ impl AsyncFutureIntrinsic {
}} else {{
this.setCopyState({future_end_class}.CopyState.IDLE);
}}
// TODO(fix): componentIdx may be -1 for the host here... is that allowed?
return {{ code: {async_event_code_enum}.FUTURE_READ, payload0: componentIdx, payload1: res }};
return {{ code: {async_event_code_enum}.FUTURE_READ, payload0: this.waitableIdx(), payload1: res }};
}};

const isReadableEnd = this.isReadable();
Expand Down Expand Up @@ -759,8 +758,7 @@ impl AsyncFutureIntrinsic {
}} else {{
this.setCopyState({future_end_class}.CopyState.IDLE);
}}
// TODO: componentIdx *may* be -1 here
return {{ code: {async_event_code_enum}.FUTURE_WRITE, payload0: componentIdx, payload1: res }};
return {{ code: {async_event_code_enum}.FUTURE_WRITE, payload0: this.waitableIdx(), payload1: res }};
}};

const onCopyDoneFn = (res) => {{
Expand Down Expand Up @@ -825,7 +823,7 @@ impl AsyncFutureIntrinsic {
if (code !== {async_event_code_enum}.FUTURE_READ) {{
throw new Error(`mismatched event code [${{code}}] for host future read`);
}}
if (index !== -1) {{ throw new Error('mismatched component idx'); }}
if (index !== this.waitableIdx()) {{ throw new Error('mismatched future end index'); }}

const vs = buffer.read(1);
if (vs.length !== 1) {{ throw new Error('multiple results from future'); }}
Expand Down Expand Up @@ -880,7 +878,7 @@ impl AsyncFutureIntrinsic {
if (code !== {async_event_code_enum}.FUTURE_WRITE) {{
throw new Error(`mismatched event code [${{code}}] for host future write`);
}}
if (index !== -1) {{ throw new Error('mismatched component idx'); }}
if (index !== this.waitableIdx()) {{ throw new Error('mismatched future end index'); }}
}}
"#
),
Expand Down Expand Up @@ -1253,7 +1251,7 @@ impl AsyncFutureIntrinsic {
if (code !== {event_code}) {{
throw new Error(`mismatched event code [${{code}}] (expected {event_code})`);
}}
if (index !== componentIdx) {{ throw new Error('mismatched component idx'); }}
if (index !== futureEnd.waitableIdx()) {{ throw new Error('mismatched future end index'); }}

return payload;
}}
Expand Down
Loading