softprops / serverless-rust

⚡ 🦀 a serverless framework plugin for rustlang applications
https://www.npmjs.com/package/serverless-rust
MIT License
545 stars 82 forks source link

Invoke Local Hangs Forever Before Deploying #57

Closed JimLynchCodes closed 4 years ago

JimLynchCodes commented 4 years ago

Hi, I scaffolded out a new function and would like to run it locally.

I don't want to actually deploy it to aws (maybe I don't even have an aws account).

Personally, I feel that one should be able to run the function locally without needing to connect and deploy to aws... maybe I am missing something here...

The issue though is that when I run the invoke local command the shell just hangs forever. :(

softprops commented 4 years ago

thanks for reaching out @JimTheMan

there two components that are likely factors here, with an possible third

1) this plugin relies on a lambci docker image to make sure the image is built in an environment that mirrors the one that it will run within. If you are not running docker. You should see an error in the console when this fails to connect to the daemon

2) serverless recently added support for invoking function functions locally from the cli for the aws runtime run time runs on. Serverless I believe also relies on docker for that.

In both of these cases. It may take some time for the docker pull to complete but it should only be a one time cost

3) there have been recent issue on the github issues list for serverless about its dependency authenticating with the aws credential chain during a package step (I'd have to poke around to find it). In any case this plugin relies to that package hook to build a binary. What you may be experiencing is not having aws credentials setup locally. You mentioned you might not have an aws account. If that's the case you definitely don't have local credentials setup!

JimLynchCodes commented 4 years ago

Thanks @softprops !

Yes, I am getting the error that it cannot connect to the docker daemon. However, I am still not sure what to do as there is not really any mention of docker in the README...

And regarding the aws credentials thing- I do have an aws account, but my point is that it should not be necessary. In other words, I want people who don't even have aws accounts to be able to scaffold a rust lambda project and run it locally. Is that not possible? It seems like a reasonable thing to me. :)

softprops commented 4 years ago

I'll update the docs.

I agree on the second point as well. I think this was the gh issue where I may have remembered here about that https://github.com/serverless/serverless/issues/6034

gg-kialo commented 4 years ago

I just gave this a go. When I don't have docker installed I get an error about that. And I can serverless invoke local without AWS credentials.

Seems like this has been resolved. Can it be closed?

JimLynchCodes commented 4 years ago

The cloudflare-workers-rust also has no README. It would be nice to explain how the project is supposed to be run...

JimLynchCodes commented 4 years ago

I just scaffolded a new one. serverless-offline gives this error:

Serverless: Starting Offline: dev/undefined.

  Error --------------------------------------------------

  Error: Missing required property "runtime" for provider.
      at ServerlessOffline._setupEvents (/Users/loaner/rust-lam/node_modules/serverless-offline/src/ServerlessOffline.js:363:13)
      at ServerlessOffline._buildServer (/Users/loaner/rust-lam/node_modules/serverless-offline/src/ServerlessOffline.js:256:10)
      at ServerlessOffline.start (/Users/loaner/rust-lam/node_modules/serverless-offline/src/ServerlessOffline.js:171:33)
      at /Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/lib/classes/PluginManager.js:490:55
      at tryCatcher (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:168:18)
      at Object.gotAccum (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues (/Users/loaner/.nvm/versions/node/v12.14.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:439:21)
      at process.topLevelDomainCallback (domain.js:130:23)
JimLynchCodes commented 4 years ago

Using serverless invoke outputs nothing in the console...

softprops commented 4 years ago

I'm aware that the serverless team is working on performance issues with invoke local https://github.com/serverless/serverless/pull/7178.

I also noticed a while back that their approach to docker building the image used to invoke local was suboptimal with some suggestions on improvements in setting up a more minimal docker build context https://github.com/serverless/serverless/issues/6895.

I'm vaguely aware that serverless offline may leverage the invoke local backend which doesn't help.

softprops commented 4 years ago

I'm going to close this for now but happy to reopen if needed.