dherault / dherault/serverless-offline
Rust is Unsupported runtime?
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 811
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
## Bug Report
After running `sls offline start` command, I try to access the API gateway by accessing: http://localhost:3000/dev/health, and then I get an HTTP error 502, while in the terminal I see that sls offline start doesn't support rust. Any idea how to fix it? Because I really want to work with rust and I don't want to deploy my lambda function each time in order to access the API gateway (yes when I deploy it, it works).
**Current Behavior**
```
Server ready: http://localhost:3000 🚀
Enter "rp" to replay the last request
GET /dev/health (λ: base_http)
Warning: Warning: found unsupported runtime 'rust' for function 'base_http'
✖ Unsupported runtime
✖ Error: Unsupported runtime
at HandlerRunner._loadRunner (/usr/lib/node_modules/serverless-offline/dist/lambda/handler-runner/HandlerRunner.js:177:11)
at HandlerRunner.run (/usr/lib/node_modules/serverless-offline/dist/lambda/handler-runner/HandlerRunner.js:215:72)
at LambdaFunction.runHandler (/usr/lib/node_modules/serverless-offline/dist/lambda/LambdaFunction.js:369:92)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async hapiHandler (/usr/lib/node_modules/serverless-offline/dist/events/http/HttpServer.js:740:18)
at async exports.Manager.execute (/usr/lib/node_modules/serverless-offline/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
at async Object.internals.handler (/usr/lib/node_modules/serverless-offline/node_modules/@hapi/hapi/lib/handler.js:46:20)
at async exports.execute (/usr/lib/node_modules/serverless-offline/node_modules/@hapi/hapi/lib/handler.js:31:20)
at async Request._lifecycle (/usr/lib/node_modules/serverless-offline/node_modules/@hapi/hapi/lib/request.js:371:32)
at async Request._execute (/usr/lib/node_modules/serverless-offline/node_modules/@hapi/hapi/lib/request.js:281:9)
```
**Sample Code**
- file: serverless.yml
```yaml
service: my-service
frameworkVersion: "3"
plugins:
- serverless-rust
- serverless-offline
provider:
runtime: rust
stage: dev
package:
individually: true
custom:
rust:
dockerless: true
functions:
base_http:
handler: base_http
events:
- http:
method: get
path: health
```
- file: main.rs
```rust
use lambda_http::{service_fn, Error, IntoResponse, Request, RequestExt};
#[tokio::main]
async fn main() -> Result<(), Error> {
lambda_http::run(service_fn(hello)).await?;
Ok(())
}
async fn hello(request: Request) -> Result {
let _context = request.lambda_context();
Ok(format!(
"hello {}",
request
.query_string_parameters()
.first("name")
.unwrap_or_else(|| "stranger")
))
}
```
**Environment**
- `serverless` version: 6.2.2
- `serverless-offline` version: 8.8.0
- `node.js` version: v16.13.2
- `npm` version: 8.5.5
- `OS`: Windows 10, Running on WSL (Ubuntu 20.04).
- `rustc` version: rustc 1.61.0 (fe5b13d68 2022-05-18)
Contributor guide
Assessment
This issue has not been assessed yet.