Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors are not reported if something else goes wrong

See original GitHub issue

It took me a long while to figure out why my program was not reporting JSON Schema errors! Here’s a much-simplified version of what was happening:

ringo:autogen$ cat t.js 
var $RefParser = require('json-schema-ref-parser');

$RefParser.dereference('some nonexistent file', function(err, schema) {
  if (err) {
  } else {

console.log('All done');
ringo:autogen$ node t.js
All done

If I comment out that last line (process.exit(0)), then the error from the missing JSON Schema is correctly reported: Error opening file "/Users/mike/git/folio/other/mod-graphql/src/autogen/some nonexistent file" ENOENT: no such file or directory.

I think what’s going on here is that, since the dereference callback function is run asynchronously, it doesn’t reach the point of reporting the ENOENT error before the program exits. But it does report the errors if the exit is explicit (i.e. fall off the end of the program) rather than explicit.

I think that errors should always be reported when they occur, irrespective of how the program terminates. Or, if that’s not possible, there should be a way to await the completion of the dereference callback function before continuing with the rest of the program.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

MikeTaylorcommented, May 23, 2018

Got it. I need the remainder of my program not to follow the dereference invocation, but to be in the callback’s no-error branch.

Thanks for helping me think more clearly about this. I agree that the issue should be closed.

JamesMessingercommented, May 23, 2018

That’s just normal Node.js async behavior. The process.exit() method is synchronous and exits the program immediately without allowing asynchronous operations any time to complete.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When Things Go Wrong: Dealing With Medical Errors
Error can be defined as failure of a planned action to be completed as intended (error of execution), or use of a wrong...
Read more >
Medical Error Reduction and Prevention - StatPearls - NCBI
Failure to report errors may subject clinicians to disciplinary action and increased risk for legal liability. Beneficence and nonmaleficence ...
Read more >
Consequences of Medical Coding & Billing Errors & How to ...
Medical coding errors can lead to more claim denials, loss of revenue, and federal penalties, fines, and imprisonment. Learn how to protect your...
Read more >
Understanding Accounting Errors, How to Detect and Prevent ...
An error of original entry is when the wrong amount is posted to an account. The error posted for the wrong amount would...
Read more >
Improvement Tip: Focus on Harm, Not Errors | IHI
For example, a wrong medication prepared and delivered to the patient may or may not cause harm. The inadequacy of the error-reporting system...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found