Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node debugger protocol #358

Merged
merged 3 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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