Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: Uncaught exceptions cause a silent exit #721
Fix: Uncaught exceptions cause a silent exit #721
Changes from all commits
7a762a8
669325b
154e07c
ab39039
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this different from
console.error
? Should we remove that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean from this line:
markbind/src/lib/markbind/src/parser.js
Line 82 in 1686253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this line:
markbind/src/util/logger.js
Line 33 in 669325b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current mechanism of logging is as follows:
We are using
logger.js
functions to print messages to the console withconsole.log()
statements and a winston-daily-rotate-file transport set to leveldebug
that writes messages to a log file.Nunjucks errors were not being logged to the console because we are not calling
logger.error()
explicitly innunjucks.renderString()
(as we don't have error handlers for these calls). Other errors do get printed to the console because we calllogger.error()
when we catch them.However, nunjucks errors were being printed to the log file because of the winston-daily-rotate-file transport.
If we want to remove
console.error
(and otherconsole.log
statements inlogger.js
), then we should use the winston console transport with the level set todebug
. There is an option to use custom formats (color, etc.) too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I am wrong,
nunjucks
is actually usingwinston-daily-rotate-file
internally? I am struggling to see how the pieces are connected here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our application does use winston through the logger, but we have also configured winston to handle logging uncaught exceptions.
markbind/src/util/logger.js
Line 15 in 6bbe1fa
That's how nunjucks errors were being logged to the log file, because we don't have error handlers for the
renderString()
calls.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking this. It answers the question originally raised by @yamgent.
How about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested this.
Let's set
winston.transports.Console
level to'info'
and then removeconsole.log
inlogger.error
,logger.warn
andlogger.info
.Sorry for the confusion regarding the
console.error
reference! I didn't realiselogger.error
was usingconsole.log
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I do these changes in this PR itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.