Elia Weiss
Elia Weiss

Reputation: 9984

VS code SAM Debugger - Error running command "sam local start-api": Timeout token cancelled

When I try to run the debugger in VS CODE with SAM hello world for Python, it creates the following in lunch.json

    {
        "type": "aws-sam",
        "request": "direct-invoke",
        "name": "API ocrSam:HelloWorldFunction",
        "invokeTarget": {
            "target": "api",
            "templatePath": "${workspaceFolder}/ocrSam/template.yaml",
            "logicalId": "HelloWorldFunction"
        },
        "api": {
            "path": "/hello",
            "httpMethod": "post",
            "payload": {
                "json": {
                    "tst": "ttt"
                }
            }
        },
        "lambda": {
            "runtime": "python3.8"
        }
    }

When I run it I get:

2023-01-06 00:43:10 [INFO]: Command: (not started) [/usr/local/bin/sam local start-api --template /tmp/aws-toolkit-vscode/vsctkDR7EPj/output/template.yaml --port 5858 --debug-port 5859 --debugger-path /home/ubuntu/.vscode-server/extensions/amazonwebservices.aws-toolkit-vscode-1.60.0/resources/debugger --debug-args /var/lang/bin/python3.8 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5859 --wait-for-client --log-to-stderr /var/runtime/bootstrap.py]
2023-01-06 00:43:10 [ERROR]: Error running command "sam local start-api": Timeout token cancelled

When I copy the cmd and try to run it from CLI I get:

/usr/local/bin/sam local start-api --template /tmp/aws-toolkit-vscode/vsctkDR7EPj/output/template.yaml --port 5858 --debug-port 5859 --debugger-path /home/ubuntu/.vscode-server/extensions/amazonwebservices.aws-toolkit-vscode-1.60.0/resources/debugger --debug-args /var/lang/bin/python3.8 /tmp/lambci_debug_files/py_debug_wrapper.py --listen 0.0.0.0:5859 --wait-for-client --log-to-stderr /var/runtime/bootstrap.py

Error: No such option: --listen

How can I by-pass this issue?

NOTE: this issue happened on my old pc which was dying, I bought a new mac and it doesn't happen any more, so it might be a specific problem of the pc

Upvotes: 1

Views: 807

Answers (1)

Josh Pinkney
Josh Pinkney

Reputation: 11

Which sam cli version do you have installed and which OS are you using?

Can you try increasing the aws.samcli.lambdaTimeout setting in the VSCode settings to something like 90000 (1.5 minutes) to see if the default timeout is too low

Upvotes: 1

Related Questions