Skip to content

Commit

Permalink
fix: cargo build throwing fallback error (#2800)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop authored Sep 9, 2024
1 parent 36aba8f commit 751759f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cli/javascript/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ fn setup_builtins(ctx: &Ctx<'_>) -> rquickjs::Result<()> {
Ok(())
}

impl LocalRuntime {
fn try_new(script: blueprint::Script) -> anyhow::Result<Self> {
impl TryFrom<blueprint::Script> for LocalRuntime {
type Error = anyhow::Error;

fn try_from(script: blueprint::Script) -> Result<Self, Self::Error> {
let source = script.source;
let js_runtime = rquickjs::Runtime::new()?;
let context = Context::full(&js_runtime)?;
context.with(|ctx| {
let _: () = context.with(|ctx| {
setup_builtins(&ctx)?;
ctx.eval(source)
})?;
Expand Down Expand Up @@ -126,7 +128,7 @@ fn init_rt(script: blueprint::Script) -> anyhow::Result<()> {
// exit if failed to initialize
LOCAL_RUNTIME.with(move |cell| {
if cell.borrow().get().is_none() {
LocalRuntime::try_new(script).and_then(|runtime| {
LocalRuntime::try_from(script).and_then(|runtime| {
cell.borrow().set(runtime).map_err(|_| {
anyhow::anyhow!("trying to reinitialize an already initialized QuickJS runtime")
})
Expand Down

1 comment on commit 751759f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 14.27ms 5.53ms 205.91ms 90.93%
Req/Sec 1.78k 208.14 2.36k 83.00%

213070 requests in 30.03s, 1.07GB read

Requests/sec: 7095.53

Transfer/sec: 36.42MB

Please sign in to comment.