Skip to content

set_hook doesn't work with async execution #347

@b0bleet

Description

@b0bleet

set_hook doesn't work properly when executing Lua with exec_async()

use anyhow::Result;
use mlua::{HookTriggers, Lua};

#[tokio::main]
async fn main() -> Result<()> {
    let lua = Lua::new();
    lua.set_hook(HookTriggers::EVERY_LINE, move |_lua, _debug| {
        println!("test hook");
        Ok(())
    });

    lua.load(
        r#"
            local x = 2 + 3
            local y = x * 63
            local z = string.len(x..", "..y)
        "#,
    )
    .exec_async()
    .await?;

    lua.remove_hook();

    Ok(())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions