second-state / wasmedge-quickjs

A high-performance, secure, extensible, and OCI-complaint JavaScript runtime for WasmEdge.
Apache License 2.0
497 stars 61 forks source link

ongoing fetch will cause cpu 100% #145

Open denghongcai opened 1 month ago

denghongcai commented 1 month ago

run code below in MacOS arm64. build wasmedge-quickjs from latest main branch, and use wasmedge 0.14.1

import { fetch } from 'http';

async function test_fetch() {
  try {
    print('test_fetch start');
    let r = await fetch('https://httpbin.org/delay/10');
    print('test_fetch\n', await r.text());
  } catch (e) {
    print(e);
  }
}

test_fetch();

during the fetch progress, seems there is a infinity loop image

L-jasmine commented 1 month ago

Although I have tried to fix this issue many times, it still has not been resolved. The underlying reason is that during the wasi poll, I continuously receive a writable status, but what I actually expect is a readable status.

I thought I had fixed it before, but it seems that’s not the case. I will keep trying.

denghongcai commented 1 month ago

https://github.com/WasmEdge/wasmedge_hyper_demo/issues/11

I found a similar problem. And I traverse wasmedge-quickjs code, the code call wasi poll through wasi_tokio?

denghongcai commented 1 month ago

I use example here https://github.com/WasmEdge/wasmedge_reqwest_demo

same behavior... sad, nothing about wasmedge-quickjs

L-jasmine commented 2 weeks ago

We found that this issue is caused by an incorrect implementation of wasi_poll in the WasmEdge runtime on macOS. The WasmEdge runtime is being fixed.