Skip to content

Missing DEBUG_PORT environment variable in nodejs stack #929

Closed
devfile/registry
#121
@rm3l

Description

@rm3l

/kind bug

Which area this bug is related to?

/area registry

What versions of software are you using?

Operating System:
Fedora 36

Go Pkg Version:

Bug Summary

Describe the bug:
The debug command declared in the devfile.yaml for NodeJS won't start when using the starter project declared in it.
The debug command runs npm run debug, and the corresponding script in the starter project runs node --inspect=${DEBUG_PORT} server.js, which expects DEBUG_PORT to be available.
Without this, the debug command errors out with the following message:

> [email protected] debug                                                
> node --inspect=${DEBUG_PORT} server.js                      
   
node: --inspect= requires an argument

To Reproduce:
Came across this issue via odo, as reported here: redhat-developer/odo#6110
This was not an issue in the past for odo because, IIUC, odo used to inject this variable automatically if not defined. But with odo v3, this is no longer the case, hence this issue.

To reproduce, you can install odo and run the commands below:

odo init --name test-nodejs --devfile nodejs --starter nodejs-starter

odo dev --debug

Expected behavior

The debug command should be running, so users can start debugging their application.

Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable.

❯ odo dev --debug                             
  __                        
 /  \__     Developing using the test-nodejs Devfile                         
 \__/  \    Namespace: default       
 /  \__/    odo version: v3.0.0-rc1                
 \__/     
                                                                                                                                                                                                                                               
↪ Deploying to the cluster in developer mode
 •  Waiting for Kubernetes resources  ...
 ⚠  Pod is Pending
 ✓  Pod is Running
 ✓  Syncing files into the container [113ms]
 ✓  Building your application in container on cluster (command: install) [3s]
 •  Executing the application (command: debug)  ...
 ✗  Finished executing the application (command: debug) [530ms]
 ⚠  Devfile command "debug" exited with an error status in 20 second(s)
 ⚠  Last 100 lines of log:
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient... 
npm WARN old lockfile

added 64 packages, and audited 65 packages in 3s 

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 8.3.1 -> 8.19.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.1> 
npm notice Run `npm install -g [email protected]` to update! 
npm notice
     
> [email protected] debug
> node --inspect=${DEBUG_PORT} server.js 

node: --inspect= requires an argument
 -  Forwarding from 127.0.0.1:40004 -> 3000

Watching for changes in the current directory /tmp/nodejs
Press Ctrl+c to exit `odo dev` and delete resources from the cluster

Additional context

Manually edit the devfile.yaml before running odo dev --debug, to add DEBUG_PORT as an environment variable in the container component.

Suggestion on how to fix the bug
Add DEBUG_PORT as an environment variable in the container component. This will also make this Devfile consistent with the other Devfiles, which contain this environment variable (cf. devfile/registry#93).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/registryDevfile registry for stacks and infrastructurekind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions