auxilincom / node-mongo

Node Mongo — is reactive 🚀 extension to MongoDB API
MIT License
5 stars 2 forks source link

Bad stack trace for error #7

Open anorsich opened 5 years ago

anorsich commented 5 years ago

With node-mongo we usually get not very helpful stack trace, like this one:

 level:  "error"   
  message:  "MongoServiceError: Document not found while updating. Query: {"_id":"5cc4a6f9361f3f0012151b4c"}
    at MongoService.update (/app/node_modules/@auxilin/node-mongo/src/MongoService.js:123:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)"   
  timestamp:  "2019-04-29T06:38:49.924Z"   

How do we improve it to show where this error has happened?

ezhivitsa commented 5 years ago

@anorsich As far as I understand the problem has appeared because Node.js can't capture stack trace inside an asynchronous function. But in Node 12 there is a flag --async-stack-traces in order to resolve the problem. But this flag should be used in the application itself.

anorsich commented 5 years ago

We'll have to wait until 2019-10-22 for Node 12 to become LTS release, but this is certainly better than nothing :) @ezhivitsa