Skip to content
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 “Sign 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

Fix incorrect logger.debug #428

Merged
merged 2 commits into from
Nov 21, 2018
Merged

Fix incorrect logger.debug #428

merged 2 commits into from
Nov 21, 2018

Conversation

impactmass
Copy link
Contributor

@impactmass impactmass commented Nov 20, 2018

Resolves: NA
Impact: minor
Type: bugfix

Issue

const logger = require("lib/logger");
logger.debug("") ==> debug is not a function

Solution

In the express app, the exported Logger is custom and only has error and appStarted methods. It is different from https://github.com/reactioncommerce/logger.

Solution: Switch to plain console.log instead.

Testing

  1. On token expiration (which is when the incorrect logger was being called), you should see the message printed and not see an error similar to:
[Network error]: SyntaxError: Unexpected token U in JSON at position 0
TypeError: _logger__WEBPACK_IMPORTED_MODULE_8___default.a.debug is not a function
    at Function._callee$ (webpack:///lib/apollo/withApolloClient.js:74:1)
    at tryCatch (/usr/local/src/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/usr/local/src/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as throw] (/usr/local/src/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (/usr/local/src/reaction-app/src/.next/server/static/development/pages/_app.js:12511:28)
    at _throw (/usr/local/src/reaction-app/src/.next/server/static/development/pages/_app.js:12537:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Extra Update

Also, we have a JSON.parse() that should be wrapped in a try/catch block to prevent exception failure. This PR also wraps that in a try/catch block. To test, just confirm that usual app usage works without errors.

@impactmass impactmass self-assigned this Nov 20, 2018
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Haven't seen the issue on this branch, seems good to me!

@kieckhafer kieckhafer merged commit 549c404 into develop Nov 21, 2018
@kieckhafer kieckhafer deleted the impactmass-patch-1 branch November 21, 2018 02:09
@impactmass impactmass mentioned this pull request Nov 21, 2018
This was referenced Jan 15, 2019
@spencern spencern mentioned this pull request Jan 25, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants