Signal Sciences NodeJS Module Troubleshooting Guide
General Tips:
- Ensure the customer has the latest version of the module installed
- Check the NodeJS version they are using as well as the version of their web frameworks
- Turn on debug and record server logs
NodeJS Version
At the moment we have tested the module with NodeJS versions 12, 14, 15 and 16. However if there are specific issues it would be good to try and reproduce those issue with the specific NodeJS version the customer is using. This can be done using Node Version Manager (nvm).
Framework Support Issues:
Not all web frameworks and not all versions of web frameworks are supported. At the moment, there is support for HAPI, express, native, restify and koa.
Debugging
It is a good idea to turn on debugging if there are issues with the module. We usually will ask for a log with debug turned on if it’s not immediately clear what the issue is or if there’s a brief error message in the logs but it’s not detailed. Turning on debugging will allow you to see more errors than you otherwise would. In order to turn on debugging for the NodeJS module you would need to add that to your userOptions when you create the SigSci object (see below).
var sigsci = new Sigsci({
host: 'agent',
port: 9090
debug: true
})
Agent Connection issues
If the module is unable to connect with the agent you should receive the following error:
SIGSCI PreRequest connection error {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":9090}
In this case we should check the SigSci userOption settings which are specified either in code when the agent integration is happening. If you are connecting via a UNIX socket you would specify the path variable (see below commented) . Otherwise, if you are connecting the module with the agent via TCP you would specify the host and port option (see below) and we should check that the agent is indeed running on that TCP port.
var sigsci = new Sigsci({
host: 'agent',
port: 9090
// path: '/tmp/sigsci-lua'
})
How to debug locally
- Install NodeJS (
brew install node) - Run the appropriate test handler for the framework you are interested in
| Framework | Test command |
|---|---|
| Native / express / restify | node --inspect test_handler.js |
| KOA | node --inspect test_handler_koa.js |
| HAPI 17 | node --inspect test_handler_hapi17.js |
| HAPI 18+ | node --inspect test_handler_hapi18.js |
curl -v 'http://localhost:8085/response?response_code=201'
Go to the following URL in Chrome chrome://inspect
Then you can place breakpoints in your Node JS code and step through them as required.
Escalating to engineering
Please include any server logs with stack traces (with debug logging enabled) as well as your package.json file.
Build failures
The build is configured to upload the NPM log file as an artifact if an NPM command fails. To find the artifact:
NOTE: NPM appears to only give a maximum 90 day access token. Check the groups 1password for token expiration, if expired, login to npm and regenerate another.
1. Click on Actions for the project.
2. Click on the Actions for the specific repository (in this case sigsci-module-nodejs)
3. Click on the specific action (usually it's the most recent one)
4. Scroll down to the bottom of the page to find the artifacts.
If you see something like npm ERR! Cannot read property '@hapi/hapi' of undefined it probably means that you used the wrong version of Node & NPM to update make sure you're using the same version specified in package.json.