aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

SAM CLI breaks at /var/runtime/index.js every time I invoke my function

Open ikamal-pxl opened this issue 5 years ago • 6 comments

Description:

I created the configurations to be able to invoke my lambda function directly using sam cli. The configuration copy is attached below (using code lens).

Screen Shot 2021-09-16 at 2 05 15 PM

When I click F5 or press the run button to debug my function it breaks every time in a file that is not in my project called index.js created in the runtime (/var/runtime/index.js) (I believe it's related to sam cli debugging feature).

This stall my development process as I expect it breaks directly at the break point I put in the code.

Steps to reproduce:

  1. Run sam init
  2. Choose option 1 (1 - AWS Quick Start Templates)
  3. Choose option 2 (2 - Image (artifact is an image uploaded to an ECR image repository)
  4. Choose option 1 (1- amazon/nodejs14.x-base)
  5. Go to app.js file then click on code lens option (add debug configuration Screen Shot 2021-09-16 at 2 15 55 PM
  6. Go to run and debug in VS code then select the function configuration you just created and then click run button Screen Shot 2021-09-16 at 2 18 58 PM

Observed result:

It breaks at an breakpoint that does not exist Screen Shot 2021-09-16 at 2 02 16 PM

Expected result:

To break at the breakpoint that I put by myself in the code

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: MacOs Big Sur version: 11.5.1
  2. sam --version: SAM CLI, version 1.31.0
  3. AWS region: US East

ikamal-pxl avatar Sep 16 '21 12:09 ikamal-pxl

Use "debugger" in your code instead breakpoint.

exports.handler = async (event, context) => {
  debugger
  console.log('event',event.body);
  return {
    statusCode: 200,
    body: JSON.stringify({
      event: event,
      context: context
    })
  }
};

pkhafizov avatar Sep 25 '21 18:09 pkhafizov

The same issue still arises. Debugging the sam application was one of the saddest days in my life. I finally created my own invokes, and like is much easier now. Thank you for your reply.

ikamal-pxl avatar Oct 05 '21 00:10 ikamal-pxl

Hi @ikamal-pxl, sorry for the experience. When I tested it, it stops in a different file first (index.js), and when I click Continue(F5) it stops at the debug point that I set in my code.

Can you confirm that continuing is also working for you? Meanwhile, we will be investigating further to fix the issue.

mndeveci avatar Oct 19 '21 22:10 mndeveci

@ikamal-pxl In your launch config you need to specify "stopOnEntry": false. https://github.com/aws/aws-sam-cli/pull/704 has some additional info on this.

jfuss avatar Dec 01 '21 18:12 jfuss

Closing as there hasn't been more information provided. Please reopen if you still encounter the issue.

torresxb1 avatar Dec 05 '22 08:12 torresxb1

I have this same issue and if I add "stopOnEntry": false it states that the property is not allowed for this configuration.

ryancabanas avatar Dec 07 '22 15:12 ryancabanas