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

オープン
#1,554 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust, wasm

調査の方向性

src/lib.rs から始めて、報告されたコマンドを再現します: cargo build、wasm-tools component new、wasm-tools component wit、続いて wasmtime serve。生成された service_only.wit の import と resource の形状を wasi:http P3 WIT および関連する Wasmtime issue と比較します。生成された形状が想定どおりかどうかを確認するか、サポートされている生成モードまたは必要な互換性変更を特定できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Rust
スター
1.5k
フォーク
306
平均マージ
1日 4時間
マージ済み PR(30日)
21

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bytecodealliance/wit-bindgen のほかの issue

bytecodealliance/wit-bindgen の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。