WasmEdge / WasmEdge

WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications. It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.

Home Page:https://WasmEdge.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `println!` in rust will make the execution terminated on the Windows environment.

HKMV opened this issue · comments

Summary

我编写了一个服务程序,当我使用println!打印时,服务无法正常运行,代码如下:

use std::net::SocketAddr;
use warp::{Filter};

#[tokio::main(flavor = "current_thread")]
async fn main() {
    // GET /
    let help = warp::get()
        .and(warp::path::end())
        .map(|| "Try POSTing data to /echo such as: `curl localhost:8080/echo -XPOST -d 'hello world'`\n");

    // POST /echo
    let echo = warp::post()
        .and(warp::path("echo"))
        .and(warp::body::bytes())
        .map(|body_bytes: bytes::Bytes| {
            format!("{}\n", std::str::from_utf8(body_bytes.as_ref()).unwrap())
        });

    let routes = help.or(echo);

    let addr = SocketAddr::from(([0, 0, 0, 0], 8080));
    // println!("Listening on http://{}", addr); //这里会导致服务无法正常运行
    warp::serve(routes).run(addr).await
}

我的系统版本是:Windows11
WasmEdge版本是:0.13.5

后来在WSL(Ubuntu22)中测试是可以正常运行的

Current State

使用println!会导致程序无故终止。

Expected State

在使用println!时程序可以正常运行

Reproduction steps

  1. Build
    cargo build --target wasm32-wasi --release
  2. Execute
    wasmedge wasmedge_hyper_server.wasm
  3. Get error
    没有错误提示,在输出println!内容后程序就停止了

Screenshots

image

Any logs you want to share for showing the specific issue

No response

Components

CLI

WasmEdge Version or Commit you used

0.13.5

Operating system information

Windows11

Hardware Architecture

amd64

Compiler flags and options

No response

Thanks for reporting this. I added the help wanted tag for those who would like to contribute to this project.