Skip to content

Should Create JavasScript Debug Terminal work for the serverless framework? #492

Closed
@jschuur

Description

I'm using the Serverless Framework to invoke local functions during testing via an NPM script and am not sure if this is supposed to work out of the box like normal node processes.

From my NPM scripts (full code at the repo):

    "update:channels": "serverless invoke local -f update_channels"

Using version 2020.5.2917, either if I click on the Debug menu above my list of NPM scripts to run this one or if I launch Debug: Create JavaScript Debug Terminal and just run npm run update:channels, it doesn't seem to attach itself to the process or hit my breakpoint:

npm run update:channels
Debugger listening on ws://127.0.0.1:61147/b7ea0a6c-9bff-445b-958b-56ac4a54a8d6
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
Debugger listening on ws://127.0.0.1:61154/13f65e37-f671-4521-bd06-9b9608478993
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
➜  learnchinese.club git:(master) npm run update:channels                                                                                          11:09
Debugger listening on ws://127.0.0.1:61160/8be1b853-6946-42b6-8125-282384c3ca47
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

> learnchinese.club@0.0.6 update:channels /Users/jschuur/Code/learnchinese.club
> serverless invoke local -f update_channels

Debugger listening on ws://127.0.0.1:61166/86101e42-9b52-4b7e-9f49-5e82dfe48019
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.

...serverless-webpack compile process and function execution output omitted...

Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...

The function just runs as if there was no breakpoint assigned.

Should it just work out of the box like this? I did notice it was listening on three different ports. Serverless also goes and compiles it via webpack first before it runs it.

On the other hand, if I launch it via this configuration in .vscode/launch.json it works:

{
      "name": "Update Channels",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/node_modules/.bin/sls",
      "args": ["invoke", "local", "-f", "update_channels"],
      "autoAttachChildProcesses": true
 }

I have a number of NPM scripts that I might like to run from the Debug menu straight in the NPM script list rather than give them all entries in launch.json. Would this be possible given my setup?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions