From feb726eee6c1e66a01243ea0243647054b691db3 Mon Sep 17 00:00:00 2001 From: Sriram Madapusi Vasudevan Date: Tue, 9 Oct 2018 16:58:44 -0700 Subject: [PATCH 1/2] fix: correct launch.json for node js debugging through vs code --- docs/usage.rst | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 8b93f11ea6..13c276a74d 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -308,21 +308,23 @@ the following launch configuration: .. code:: json - { - "version": "0.2.0", - "configurations": [ - { - "name": "Attach to SAM CLI", - "type": "node", - "request": "attach", - "address": "localhost", - "port": 5858, - "localRoot": "${workspaceRoot}", - "remoteRoot": "/var/task", - "protocol": "legacy" - } - ] - } + { + "version": "0.2.0", + "configurations": [{ + "name": "Attach to SAM CLI", + "type": "node", + "request": "attach", + "address": "localhost", + "port": 5858, + "localRoot": "${workspaceRoot}", + "sourceMapPathOverrides": { + "${workspaceRoot}/runtime": "${remoteRoot}" + }, + "remoteRoot": "/var/task", + "protocol": "inspector", + "stopOnEntry": false + }] + } Note: Node.js versions --below-- 7 (e.g. Node.js 4.3 and Node.js 6.10) use the ``legacy`` protocol, while Node.js versions including and above From db6736bccab47eb5e7324a8902882216e6d30d99 Mon Sep 17 00:00:00 2001 From: Sriram Madapusi Vasudevan Date: Thu, 11 Oct 2018 16:01:09 -0700 Subject: [PATCH 2/2] refactor: node js debugging - launch.json - Remove source path mapping - Add a note for the localRoot being based on the where the function code resides. This is referenced by CodeUri inside template.yaml - Add a note on where VS code needs to be opened. --- docs/usage.rst | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 13c276a74d..34700084b8 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -304,33 +304,39 @@ Visual Studio Code: SAM Local debugging example In order to setup Visual Studio Code for debugging with AWS SAM CLI, use -the following launch configuration: +the following launch configuration after setting directory where the template.yaml is present +as workspace root in Visual Studio Code: .. code:: json - { - "version": "0.2.0", - "configurations": [{ - "name": "Attach to SAM CLI", - "type": "node", - "request": "attach", - "address": "localhost", - "port": 5858, - "localRoot": "${workspaceRoot}", - "sourceMapPathOverrides": { - "${workspaceRoot}/runtime": "${remoteRoot}" - }, - "remoteRoot": "/var/task", - "protocol": "inspector", - "stopOnEntry": false - }] - } + { + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to SAM CLI", + "type": "node", + "request": "attach", + "address": "localhost", + "port": 5858, + // From the sam init example, it would be "${workspaceRoot}/hello_world" + "localRoot": "${workspaceRoot}/{directory of node app}", + "remoteRoot": "/var/task", + "protocol": "inspector", + "stopOnEntry": false + } + ] + } + +Note: localRoot is set based on what the CodeUri points at template.yaml, +if there are nested directories within the CodeUri, that needs to be +reflected in localRoot. Note: Node.js versions --below-- 7 (e.g. Node.js 4.3 and Node.js 6.10) use the ``legacy`` protocol, while Node.js versions including and above 7 (e.g. Node.js 8.10) use the ``inspector`` protocol. Be sure to specify the corresponding protocol in the ``protocol`` entry of your launch -configuration. +configuration. This was tested with VS code version 1.26, 1.27 and 1.28 +for ``legacy`` and ``inspector`` protocol. Debugging Python functions --------------------------