{"id":18930160,"url":"https://github.com/nheidloff/openwhisk-debug-nodejs","last_synced_at":"2025-09-23T03:50:05.246Z","repository":{"id":88375185,"uuid":"115089442","full_name":"nheidloff/openwhisk-debug-nodejs","owner":"nheidloff","description":"Debugging Node.js OpenWhisk Functions in Visual Studio Code","archived":false,"fork":false,"pushed_at":"2018-03-21T01:24:07.000Z","size":6841,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T17:16:06.235Z","etag":null,"topics":["debugging","functions-as-a-service","ibm-cloud","node","nodejs","openwhisk","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nheidloff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-22T07:30:29.000Z","updated_at":"2024-05-18T10:11:35.000Z","dependencies_parsed_at":"2024-03-30T16:00:34.378Z","dependency_job_id":null,"html_url":"https://github.com/nheidloff/openwhisk-debug-nodejs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nheidloff/openwhisk-debug-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-debug-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-debug-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-debug-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-debug-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nheidloff","download_url":"https://codeload.github.com/nheidloff/openwhisk-debug-nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nheidloff%2Fopenwhisk-debug-nodejs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276512733,"owners_count":25655450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-23T02:00:09.130Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugging","functions-as-a-service","ibm-cloud","node","nodejs","openwhisk","serverless"],"created_at":"2024-11-08T11:36:48.387Z","updated_at":"2025-09-23T03:50:05.230Z","avatar_url":"https://github.com/nheidloff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Debugging Node.js OpenWhisk Functions in VS Code\n\nThis [project](https://github.com/nheidloff/openwhisk-debug-nodejs) shows how [Apache OpenWhisk](http://openwhisk.org/) functions can be developed and debugged locally via [Visual Studio Code](https://code.visualstudio.com/).\n\nThis project doesn't contain a new tool or OpenWhisk extension. Instead it contains sample functions and configurations of VS Code that explain how to debug your own OpenWhisk functions.\n\nYou don't need to use Docker to debug functions unless you want to write your functions in Docker containers. In the simplest case clone the repo, overwrite the samples in functions/singleFile with your own code and run the debug configurations.\n\nFive different scenarios are supported:\n\n* Single file JavaScript functions (synch and asynch)\n* Zipped JavaScript functions with additional npm dependencies\n* JavaScript functions running in Docker containers\n* Dockerized JavaScript functions running in the local Node.js runtime\n* TypeScript functions running in Docker containers\n\nWatch the [video](https://www.youtube.com/watch?v=P9hpcOqQ3hw) to see this in action.\n\nThe following screenshot shows how functions that run in Docker can be debugged from Visual Studio Code. In order to do this, a volume is used to share the files between the IDE and the container and VS Code attaches a remote debugger to the Docker container. The functions can be changed in the IDE without having to restart the container. [nodemon](https://github.com/remy/nodemon) restarts the Node application in the container automatically when files change.\n\n![alt text](https://github.com/nheidloff/openwhisk-debug-nodejs/raw/master/images/debugging-docker-3.png \"Debugging\")\n\n\n## Prerequisites and Setup\n\nIn order to run the code you need the following prerequisites and you need to set up your system.\n\n**Prerequisites**\n\nMake sure you have the following tools installed:\n\n* [Visual Studio Code](https://code.visualstudio.com/)\n* [Node](https://nodejs.org/en/download/)\n* [Docker](https://docs.docker.com/engine/installation/)\n* [git](https://git-scm.com/downloads)\n* [IBM Cloud account](https://ibm.biz/nheidloff)\n\n\n**Setup**\n\nRun the following commands:\n\n```sh\n$ git clone https://github.com/nheidloff/openwhisk-debug-nodejs.git\n$ cd openwhisk-debug-nodejs\n$ npm install\n$ code .\n```\n\n**Debugging from Visual Studio Code**\n\nThere are two ways to start the debugger in VS Code:\n\n* From the [debug page](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/start-debugger-ui.png) choose the specific launch configuration\n* Open the [command palette](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/start-debugger-palette-1.png) (⇧⌘P) and search for 'Debug: Select and Start Debugging' or enter 'debug se'. After this select the specific [launch configuration](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/start-debugger-palette-2.png)\n\n\n## Debugging Single File Functions\n\nThere are three sample functions:\n\n* [function.js](functions/singleFile/function.js)\n* [functionAsynch.js](functions/singleFile/functionAsynch.js)\n* [functionAsychReject.js](functions/singleFile/functionAsychReject.js)\n\n**Debugging**\n\nTo run and debug the functions, you can define the input as JSON in [payload.json](payloads/payload.json). In order to debug the functions, set breakpoints in the code.\n\nRun the launch configurations 'function.js', 'functionAsynch.js' and 'functionAsychReject.js' to run and debug the functions - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-single-file-1.png).\n\n**Deployment and Invocation**\n\nIn order to deploy the functions to IBM Cloud Functions, replace 'your-ibm-cloud-organization' and 'your-ibm-cloud-space' and run the following commands:\n\n```sh\n$ bx login -a api.ng.bluemix.net\n$ bx target -o \u003cyour-ibm-cloud-organization\u003e -s \u003cyour-ibm-cloud-space\u003e\n$ bx plugin install Cloud-Functions -r Bluemix\n$ cd openwhisk-debug-nodejs/functions/singleFile\n$ bx wsk action create function function.js\n$ bx wsk action invoke --blocking function --param name Niklas\n$ bx wsk action create functionAsynch functionAsynch.js\n$ bx wsk action invoke --blocking functionAsynch --param name Niklas\n$ bx wsk action create functionAsynchReject functionAsynchReject.js\n$ bx wsk action invoke --blocking functionAsynchReject --param name Niklas\n```\n\nAfter you've changed the functions and created them on IBM Cloud Functions, use 'bx wsk action update' instead of 'bx wsk action create'.\n\n\n## Debugging Zipped Functions\n\nThere is a sample function [functionAsynch.js](functions/zip/functionAsynch.js) that shows how to use a npm module which is not supported by the standard [OpenWhisk Node runtime](https://hub.docker.com/r/openwhisk/nodejs6action/~/dockerfile/).\n\n**Debugging**\n\nTo run and debug the function, you can define the input as JSON in [payload.json](payloads/payload.json). In order to debug the function, set breakpoints in [functionAsynch.js](functions/zip/functionAsynch.js).\n\nInstall the npm modules:\n\n```sh\n$ cd openwhisk-debug-nodejs/functions/zip\n$ npm install\n```\n\nRun the launch configurations 'zip' to run and debug the function - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-zip.png).\n\n**Deployment and Invocation**\n\nIn order to deploy the functions to IBM Cloud Functions, replace 'your-ibm-cloud-organization' and 'your-ibm-cloud-space' and run the following commands:\n\n```sh\n$ bx login -a api.ng.bluemix.net\n$ bx target -o \u003cyour-ibm-cloud-organization\u003e -s \u003cyour-ibm-cloud-space\u003e\n$ bx plugin install Cloud-Functions -r Bluemix\n$ cd openwhisk-debug-nodejs/functions/zip\n$ sh deploy.sh\n$ bx wsk action invoke --blocking zippedFunctionAsynch --param name Niklas\n```\n\nAfter you've changed the function and created it on IBM Cloud Functions, use 'bx wsk action update' instead of 'bx wsk action create' in [deploy.sh](functions/zip/deploy.sh).\n\n\n## Debugging Functions in Docker Containers\n\nThere is a sample function [function.js](functions/docker/function.js) that shows how to write an OpenWhisk function running in a container by implementing the endpoints '/init' and '/run'.\n\nThe function can be changed in the IDE without having to restart the container after every change. Instead a mapped volume is used to share the files between the IDE and the container and [nodemon](https://github.com/remy/nodemon) restarts the Node application in the container automatically when files change.\n\n**Debugging**\n\nRun the following commands in a terminal to run the container - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-docker-1.png):\n\n```sh\n$ cd openwhisk-debug-nodejs/functions/docker\n$ docker-compose up --build\n```\n\nRun the launch configurations 'function in container' to attach the debugger - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-docker-2.png).\n\nYou can define the input as JSON in [payload.json](payloads/payload.json). Set breakpoints in [function.js](functions/docker/function.js). After this invoke the endpoints in the container by running these commands from a second terminal - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-docker-3.png).\n\n```sh\n$ cd openwhisk-debug-nodejs\n$ node runDockerFunction.js\n```\n\nYou'll see the output of the function in the terminal - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-docker-4.png).\n\nAfter you're done stop the container via these commands in the first terminal - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-docker-5.png):\n\n```sh\n$ cd openwhisk-debug-nodejs/functions/docker\n$ docker-compose down\n```\n\n**Deployment and Invocation**\n\nIn order to deploy the functions to IBM Cloud Functions, replace 'your-ibm-cloud-organization', 'your-ibm-cloud-space' and 'dockerhub-name' and run the following commands:\n\n```sh\n$ bx login -a api.ng.bluemix.net\n$ bx target -o \u003cyour-ibm-cloud-organization\u003e -s \u003cyour-ibm-cloud-space\u003e\n$ bx plugin install Cloud-Functions -r Bluemix\n$ cd openwhisk-debug-nodejs/functions/docker\n$ docker build -t \u003cdockerhub-name\u003e/openwhisk-docker-nodejs-debug:latest .\n$ docker push \u003cdockerhub-name\u003e/openwhisk-docker-nodejs-debug\n$ bx wsk action create actionDocker --docker \u003cdockerhub-name\u003e/openwhisk-docker-nodejs-debug:latest\n$ bx wsk action invoke --blocking actionDocker --param name Niklas\n```\n\n\n## Debugging dockerized Functions\n\nYou can run and debug the same dockerized function [function.js](functions/docker/function.js) in your local Node.js runtime without Docker.\n\n**Debugging**\n\nRun these commands to install the dependencies:\n\n```sh\n$ cd openwhisk-debug-nodejs/functions/docker\n$ npm install\n```\n\nRun the launch configurations 'dockerized function' to launch the debugger - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-dockerized-1.png).\n\nYou can define the input as JSON in [payload.json](payloads/payload.json). Set breakpoints in [function.js](functions/docker/function.js). After this invoke the endpoints in the container by running these commands from a terminal - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-dockerized-3.png).\n\n```sh\n$ cd openwhisk-debug-nodejs\n$ node runDockerFunction.js\n```\n\n**Deployment and Invocation**\n\nSee above. This is identical to 'Debugging Functions in Docker Containers'.\n\n\n## Debugging TypeScript Functions in Docker Containers\n\nThere is a sample function [function.ts](functions/typescript/src/function.ts) that shows how to write an OpenWhisk function in TypeScript running in a container by implementing the endpoints '/init' and '/run'.\n\nThe function can be changed in the IDE without having to restart the container after every change. Instead a mapped volume is used to share the files between the IDE and the container and [nodemon](https://github.com/remy/nodemon) restarts the Node application in the container automatically when files change.\n\n**Debugging**\n\nRun the launch configurations 'typescript function' to start the container and to attach the debugger - see [screenshot](https://github.com/nheidloff/openwhisk-debug-nodejs/blob/master/images/debugging-typescript.png).\n\nYou can define the input as JSON in [payload.json](payloads/payload.json). Set breakpoints in [function.ts](functions/typescript/src/function.ts). After this invoke the endpoints in the container by running these commands from a second terminal.\n\n```sh\n$ cd openwhisk-debug-nodejs\n$ node runDockerFunction.js\n```\n\nYou'll see the output of the function in the terminal.\n\nAfter you're done stop the container via these commands in the first terminal.\n\n```sh\n$ cd openwhisk-debug-nodejs/functions/typescript\n$ docker-compose down\n```\n\n**Deployment and Invocation**\n\nIn order to deploy the functions to IBM Cloud Functions, replace 'your-ibm-cloud-organization', 'your-ibm-cloud-space' and 'dockerhub-name' and run the following commands:\n\n```sh\n$ bx login -a api.ng.bluemix.net\n$ bx target -o \u003cyour-ibm-cloud-organization\u003e -s \u003cyour-ibm-cloud-space\u003e\n$ bx plugin install Cloud-Functions -r Bluemix\n$ cd openwhisk-debug-nodejs/functions/typescript\n$ docker build -t \u003cdockerhub-name\u003e/openwhisk-docker-typescript-debug:latest .\n$ docker push \u003cdockerhub-name\u003e/openwhisk-docker-typescript-debug\n$ bx wsk action create actionTypeScript --docker \u003cdockerhub-name\u003e/openwhisk-docker-typescript-debug:latest\n$ bx wsk action invoke --blocking actionTypeScript --param name Niklas\n```\n\n\n## Resources\n\nTo find out more about how to develop OpenWhisk functions locally, check out the following resources:\n\n* [Advanced debugging of OpenWhisk actions](https://medium.com/openwhisk/advanced-debugging-of-openwhisk-actions-518414636932)\n* [wskdb: The OpenWhisk Debugger](https://github.com/apache/incubator-openwhisk-debugger)\n* [Testing node.js functions locally](https://github.com/apache/incubator-openwhisk-devtools/tree/master/node-local)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnheidloff%2Fopenwhisk-debug-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnheidloff%2Fopenwhisk-debug-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnheidloff%2Fopenwhisk-debug-nodejs/lists"}