wasi:http/service p3 component generated by wit-bindgen is rejected by wasmtime serve (wasi:http/types resource mismatch)

Đang mở
#1,554 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust, wasm

Hướng nghiên cứu

Bắt đầu với src/lib.rs và tái hiện các lệnh đã được báo cáo: cargo build, wasm-tools component new, wasm-tools component wit, sau đó là wasmtime serve. So sánh import và dạng tài nguyên được tạo của service_only.wit với wasi:http P3 WIT và issue Wasmtime liên quan; hoàn tất khi xác định được liệu dạng được tạo có đúng như mong đợi hay đã xác định được một chế độ tạo được hỗ trợ hoặc thay đổi tương thích cần thiết.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Using wit-bindgen (crate 0.51.0) to generate a wasi:http/[email protected] component produces a valid component (wasm-tools validate passes), but the generated import shape appears incompatible with wasmtime serve.

Related wasmtime issue: https://github.com/bytecodealliance/wasmtime/issues/12714

Versions

  • wit-bindgen crate: 0.51.0
  • rustc: 1.92.0
  • wasm-tools: 1.245.1
  • wasmtime: 41.0.3

Repro

src/lib.rs:

wit_bindgen::generate!({
    inline: r#"
      package vibe:http-adapter;

      world serviceonly {
        include wasi:http/[email protected];
      }
    "#,
    path: "<wasmtime repo>/crates/wasi-http/src/p3/wit",
    world: "vibe:http-adapter/serviceonly",
    pub_export_macro: true,
    generate_all,
});

use exports::wasi::http::handler::Guest;
use wasi::http::types::{ErrorCode, Request, Response};

struct Component;

impl Guest for Component {
    async fn handle(request: Request) -> Result<Response, ErrorCode> {
        let _ = request;
        Err(ErrorCode::InternalError(None))
    }
}

export!(Component);
cargo build --target wasm32-unknown-unknown --release
wasm-tools component new target/wasm32-unknown-unknown/release/<crate>.wasm -o service_only.component.wasm
wasm-tools component wit service_only.component.wasm > service_only.wit

Generated service_only.wit starts as:

package root:component;

world root {
  import wasi:http/[email protected];

  export wasi:http/[email protected];
}
package wasi:[email protected] {
  interface types {
    resource request;
    resource response;
    ...

Then wasmtime serve fails:

instance export `request` has the wrong type
resource implementation is missing

Question

Is this import/type shape expected from wit-bindgen for P3 wasi:http/service, or should wit-bindgen preserve a fuller types resource shape so hosts can link canonical wasi:http/types implementations?

If this is expected behavior, is there a recommended generation mode/flag to avoid this incompatibility?

Ngôn ngữ chính
Rust
Star
1.5k
Fork
306
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bytecodealliance/wit-bindgen

Tất cả issue của bytecodealliance/wit-bindgen

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.