Skip to content

Commit

Permalink
Fix node debugger protocol (#358)
Browse files Browse the repository at this point in the history
* Use legacy debugger for Node 6.10

* Document which debugger protocol to use

* Making Node8 debugging work
  • Loading branch information
bradydowling authored and sanathkr committed Apr 11, 2018
1 parent 290b208 commit a04b791
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -229,7 +229,7 @@ $ sam local invoke -d 5858 <function logical id>
$ 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:

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions runtime.go
Expand Up @@ -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",
Expand All @@ -511,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",
Expand Down

0 comments on commit a04b791

Please sign in to comment.