You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am very aware that Bun is not Node and isn't strictly supported by napi-rs, however the Bun team have on their docs that they support a majority of the Node API.
I have a simple async function in Rust which uses Reqwest to make a HTTP request:
use napi_derive::napi;#[napi]pubasyncfnget_data(user_id:String) -> String{let val = match reqwest::get(format!("https://example.com/api/users/{}",
user_id
)).await{Ok(val) => val,Err(e) => {println!("{:#?}", e);return"broken :(".to_owned();}};
val.text().await.unwrap()}
When I run this via Node it works perfectly, the program waits and makes the request and I get the response back as I'd expect. However, when I run the exact same code with Bun the program just exits before any of the async code is polled, any blocking code before the async request works fine as expected but for some reason anything which requires async polling instantly closes bun. It doesn't appear to be a crash, I think it just thinks it's done.
I am aware it's not supported but I wanted to ask why might this be the case, I'm not sure why this doesn't work on Bun so I wanted to ask the people which would know better than I.
I am very aware that Bun is not Node and isn't strictly supported by napi-rs, however the Bun team have on their docs that they support a majority of the Node API.
I have a simple async function in Rust which uses Reqwest to make a HTTP request:
When I run this via Node it works perfectly, the program waits and makes the request and I get the response back as I'd expect. However, when I run the exact same code with Bun the program just exits before any of the async code is polled, any blocking code before the async request works fine as expected but for some reason anything which requires async polling instantly closes bun. It doesn't appear to be a crash, I think it just thinks it's done.
I am aware it's not supported but I wanted to ask why might this be the case, I'm not sure why this doesn't work on Bun so I wanted to ask the people which would know better than I.
Bun's NAPI impl tracking issue: oven-sh/bun#158
The text was updated successfully, but these errors were encountered: