Skip to content

Lambda Handler #1

@skorfmann

Description

@skorfmann

Trying to build a Rust Lambda Handler (based on https://github.com/awslabs/aws-lambda-rust-runtime). However, when integrating this I get the following error:

error: future cannot be sent between threads safely
   --> cloud/lib/rust-runtime/src/main.rs:37:9
    |
37  |     run(service_fn(function_handler)).await
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `function_handler` is not `Send`
    |
    = help: within `impl std::future::Future<Output = Result<lambda_http::Response<lambda_http::Body>, Box<(dyn StdError + std::marker::Send + std::marker::Sync + 'static)>>>`, the trait `std::marker::Send` is not implemented for `Rc<FsModuleLoader>`
note: future is not `Send` as this value is used across an await
   --> /Users/sebastian/projects/byt/runtime/runtime/myworker/mod.rs:182:61
    |
110 |     let module_loader = Rc::new(FsModuleLoader);
    |         ------------- has type `Rc<FsModuleLoader>` which is not `Send`
...
182 |     let module_id = worker.preload_main_module(&main_module).await.unwrap();
    |                                                             ^^^^^^ await occurs here, with `module_loader` maybe used later
...
186 | }
    | - `module_loader` is later dropped here
note: required by a bound in `lambda_http::run`
   --> /Users/sebastian/.cargo/registry/src/github.com-1ecc6299db9ec823/lambda_http-0.7.3/src/lib.rs:185:16
    |
185 |     S::Future: Send + 'a,
    |                ^^^^ required by this bound in `lambda_http::run`

Have tried to move around a few things without much success, just slightly different error descriptions of the same category.

The relevant code for the lambda handler is here and the runtime

Any idea @certainty ?

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