From 192cf0fbbc5a4cefda3f824eb816717281032475 Mon Sep 17 00:00:00 2001 From: Brady Dowling Date: Mon, 9 Apr 2018 20:54:48 +0000 Subject: [PATCH 1/3] Use legacy debugger for Node 6.10 --- runtime.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime.go b/runtime.go index 32b7d686a1..62fc80c379 100644 --- a/runtime.go +++ b/runtime.go @@ -496,8 +496,7 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) { } overrides = append(overrides, debuggerArgsArray...) overrides = append(overrides, - "--inspect="+r.DebugPort, - "--debug-brk", + "--debug-brk="+r.DebugPort, "--nolazy", "--max-old-space-size=2547", "--max-semi-space-size=150", From c42d13e20a098edef64e5b7a58ec7bc0d4113721 Mon Sep 17 00:00:00 2001 From: Brady Dowling Date: Mon, 9 Apr 2018 20:55:16 +0000 Subject: [PATCH 2/3] Document which debugger protocol to use --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 64600cffce..2635677aca 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ $ sam local invoke -d 5858 $ sam local start-api -d 5858 ``` -Note: If using `sam local start-api`, the local API Gateway will expose all of your lambda functions but, since you can specify a single debug port, you can only debug one function at a time. You will need to hit your api before Sam Local binds to the port allowing the debugger to connect. +Note: If using `sam local start-api`, the local API Gateway will expose all of your Lambda functions but, since you can specify a single debug port, you can only debug one function at a time. You will need to hit your API before SAM Local binds to the port allowing the debugger to connect. Here is an example showing how to debug a NodeJS function with Microsoft Visual Studio Code: @@ -249,13 +249,13 @@ In order to setup Visual Studio Code for debugging with AWS SAM Local, use the f "port": 5858, "localRoot": "${workspaceRoot}", "remoteRoot": "/var/task", - "protocol": "inspector" + "protocol": "legacy" } ] } ``` -Note: You must detach your debugger in order for the result to be sent back to AWS SAM Local. +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. #### Debugging Python functions From 44920b006cce8c24708852dcfe50b01cd5c8a02a Mon Sep 17 00:00:00 2001 From: Sanath Kumar Ramesh Date: Tue, 10 Apr 2018 16:43:19 -0700 Subject: [PATCH 3/3] Making Node8 debugging work --- runtime.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime.go b/runtime.go index 62fc80c379..75e74315b6 100644 --- a/runtime.go +++ b/runtime.go @@ -510,8 +510,9 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) { } overrides = append(overrides, debuggerArgsArray...) overrides = append(overrides, - "--inspect="+r.DebugPort, - "--debug-brk", + // Node8 requires the host to be explicitly set in order to bind to localhost instead of 127.0.0.1 + // https://github.com/nodejs/node/issues/11591#issuecomment-283110138 + "--inspect-brk=0.0.0.0:"+r.DebugPort, "--nolazy", "--expose-gc", "--max-semi-space-size=150",