serverless-google-cloudfunctions icon indicating copy to clipboard operation
serverless-google-cloudfunctions copied to clipboard

"invoke local" doesn't do anything

Open kennedyrose opened this issue 7 years ago • 16 comments

I'm using the default Node.js template. Running invoke works perfectly fine on the deployed application, but running sls invoke local -f first doesn't do anything or print anything to the console.

When logging debug info no errors are shown. It gets to Serverless: Invoke invoke:local then the process just exits.

kennedyrose avatar Oct 29 '18 19:10 kennedyrose

Same here.

Any updates about it?

ghost avatar Nov 28 '18 13:11 ghost

Same here.

Any updates about it?

evmartinelli avatar Feb 09 '19 19:02 evmartinelli

Is there a workaround for this issue ?

fperron01 avatar Mar 29 '19 20:03 fperron01

Just ran into this problem, it seems to happen when two conditions are met:

  • you run the sls invoke local command via a debugger (Vscode in my case), and:
  • no input data was provided to invoke local (via either data or path parameters).

In that scenario, InvokeLocal plugin gets stuck trying to read data on stdin. The problem seems to be located in get-stdin/index.js, where the condition if (stdin.isTTY) is false for some reason. May be related to the way VScode calls programs to debug?!

An easy workaround is to add a dummy --data or --path parameter to your invoke local command.

kindofbeard avatar May 22 '19 09:05 kindofbeard

this workaround worked for you? I tried and fails here :(

evmartinelli avatar May 22 '19 14:05 evmartinelli

This one doesn't work for me as well Any updates on this issue?

buffolander avatar Jul 16 '19 11:07 buffolander

Well yes I confirm, the following config "just works" for me right now:

` {

  "type": "node",

  "request": "launch",

  "name": "Test running lambda sls",

  "program": "${workspaceFolder}/node_modules/.bin/sls",

  "args": [

    "invoke",

    "local",

    "-f",

    "myLambdaFunction",

    "--data",

    "dummyData"

  ]

} `

If I remove the "--data dummyData" section, Invoke Lambda gets stuck as before. Latest Vscode, and my OS is an Ubuntu 18.04 LTS in case it matters...

kindofbeard avatar Jul 17 '19 12:07 kindofbeard

Just ran into this problem, it seems to happen when two conditions are met:

  • you run the sls invoke local command via a debugger (Vscode in my case), and:
  • no input data was provided to invoke local (via either data or path parameters).

In that scenario, InvokeLocal plugin gets stuck trying to read data on stdin. The problem seems to be located in get-stdin/index.js, where the condition if (stdin.isTTY) is false for some reason. May be related to the way VScode calls programs to debug?!

An easy workaround is to add a dummy --data or --path parameter to your invoke local command.

Yeah, this workaround works for me also. I'm using windows 10 and git bash

johku90 avatar Aug 06 '19 06:08 johku90

Any update for this? Workaround dont work for me. When i invoke in shell

serverless invoke local -f first --data '{"name": "Bernie"}'

nothing happens. this doesn't do anything or print anything to the console

sadowskipawel avatar Oct 11 '19 07:10 sadowskipawel

I also run into this issue as well. The debug output looks like this:

Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Invoke invoke:local

Afterwards it stops and the return value is 0.

roenschg avatar Oct 24 '19 09:10 roenschg

I am experiencing the same thing, except rather than hanging it just exits after "Serverless: Invoke invoke:local" with no output or even attempting to compile the code (introducing a deliberate syntax error doesn't have any effect). Seems like maybe this plugin is not ready for use?

parkan avatar Aug 05 '20 21:08 parkan

Same issue here. serverless invoke local fails to produce any output, whereas the deployed function does output "Hello world". I am using Google Cloud Shell for my dev environment.

scarolan avatar Dec 26 '20 16:12 scarolan

try this (assuming hello is your function name)

sls invoke local -f hello -d

prakis avatar Feb 10 '21 14:02 prakis

Can't get it to work either.

neoromantic avatar Feb 25 '21 15:02 neoromantic

I assume this isn't the problem any of you all are running into, but since I had the exact same symptoms (sls invoke local -f user-endpoint --data "{}" -l runs for a second and returns with no output) and wound up here from google, here was my fix:

I was running the command from the wrong director. As soon as I cd'd to the the directory containing my serverless.yml file, it worked fine. 🤦‍♂️

kkuchta avatar Mar 04 '21 19:03 kkuchta

Same issue, I am using it alongside "serverless-plugin-typescript", after a lot of attempts to fix it the local invocation does not work. It compiles but will not invoke.

hammadzz avatar Jun 07 '21 01:06 hammadzz