8000 Use module logging utility · Issue #132 · pnxtech/hydra-express · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use module logging utility #132

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 “S 8000 ign 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

Open
tylerhutcherson opened this issue Nov 23, 2021 · 5 comments
Open

Use module logging utility #132

tylerhutcherson opened this issue Nov 23, 2021 · 5 comments

Comments

@tylerhutcherson
Copy link

An error in my Node JS application is throwing a hydra-express related exception (and covering up the real issue on my end):

TypeError: this.appLogger.fatal is not a function
    at /usr/src/app/node_modules/hydra-express/index.js:487:26
    at Layer.handle_error (/usr/src/app/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:315:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at Layer.handle_error (/usr/src/app/node_modules/express/lib/router/layer.js:67:12)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:315:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at Layer.handle_error (/usr/src/app/node_modules/express/lib/router/layer.js:67:12)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:315:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at param (/usr/src/app/node_modules/express/lib/router/index.js:354:14)
    at param (/usr/src/app/node_modules/express/lib/router/index.js:365:14)

Based on the trace, I believe the culprit is here:

this.appLogger.fatal({
and should use this.log('fatal', {msg}) instead.

We are running with the following dependencies:

  "dependencies": {
    "redis": "2.8.0",
    "hydra-express": "1.8.3",
    "hydra-express-plugin-jwt-simple-auth": "0.1.0",
    "hydra-plugin-hls": "0.2.6",
    "node-fetch": "2.6.1"
  },
@tylerhutcherson
Copy link
Author
tylerhutcherson commented Nov 29, 2021

@cjus Our app in question is already using the following package.json:

{
  "name": "shopify-webhooks-v1-svcs",
  "version": "0.1.3",
  "description": "Shopify Webhooks",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "redis": "2.8.0",
    "hydra-express": "1.8.3",
    "hydra-express-plugin-jwt-simple-auth": "0.1.0",
    "hydra-plugin-hls": "0.2.6",
    "node-fetch": "2.6.1"
  },
  "devDependencies": {
    "eslint": "7.15.0",
    "eslint-config-google": "0.14.0"
  }
}

@tylerhutcherson
Copy link
Author
tylerhutcherson commented Nov 29, 2021

Looks like our app has the dependency, but the hydra-plugin-hls is not getting loaded/configured for us with hydraExpress. Our app has the following imports:

 const hydraExpress = require('hydra-express');
 const express = hydraExpress.getExpress();
 const hydra = hydraExpress.getHydra();
 const ServerResponse = hydra.getServerResponseHelper();
 const serverResponse = new ServerResponse;

 const api = new express.Router();

Am I correct that the proper import for hls plugin would be:

 const hydraExpress = require('hydra-express');
 const HydraLogPlugin = require('hydra-plugin-hls/hydra-express');
 hydraExpress.use(new HydraLogPlugin);

 const express = hydraExpress.getExpress();
 const hydra = hydraExpress.getHydra();
 const ServerResponse = hydra.getServerResponseHelper();
 const serverResponse = new ServerResponse;

 const api = new express.Router();

@tylerhutcherson
Copy link
Author

I tested this update on our app, yet I still get the same error thrown by the hydra-express lib above.

@cjus
Copy link
Contributor
cjus commented Dec 1, 2021

@tylerhutcherson is there any chance that your exception is occurring before the logging plugin is bound?
Happy to help debug this via zoom. You have my contact info.

@tylerhutcherson
Copy link
Author

@tylerhutcherson is there any chance that your exception is occurring before the logging plugin is bound? Happy to help debug this via zoom. You have my contact info.

It appears the true exception under the hood was an express PayloadTooLargeError described here. This was being covered up by the error posted above. When I removed the hydra logging plugin entirely, the exception passed through, enabling us to debug the real issue.

However - the error above seems to happen when there is a fatal log-level error inside the middleware.

This is currently non-blocking for us at the moment, however, I can leave this open if you want, or we can take the discussion offline and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0