ChickenKyiv / loopback-tutor-intern-18

GNU General Public License v3.0
0 stars 0 forks source link

sentry/raven configuration #2

Closed atherdon closed 6 years ago

atherdon commented 6 years ago

Raven.config('https://77aa2ee9a7ce484497f56278982a0809@sentry.io/305339').install()

Init: https://github.com/GroceriStar/groceristar/blob/master/server/server.js#L17

How to use this tracer: https://github.com/GroceriStar/groceristar/blob/master/server/server.js#L60

if you'll cover your code well with this tracer - when you'll break something - I'll receive an email notification and will be able to understand more clearly what was goes wrong.

image

JorgeRodr commented 6 years ago

@atherdon I implemented this only in reservation.js because I didn't think it would be useful in the rest of the app at least for the moment... correct me if I'm wrong.

I have one question,Ihave refactored the reservations code to use async/await but I have problems with "next()" callback. Before the refactoring I was calling it at the end of Reservation.observe and it was ok, but now that I am using async/await it throws an error (callback already called and another one that i can't remember now) and I don't know why. I decided remove the call and now all works ok as before... I think one of the problems is that I don't know what is the next() callback for.

atherdon commented 6 years ago

give me the code link, because it's hard to get into your question

On 27-May-2018 at 10:06 PM, JorgeRodr wrote:

@atherdon https://github.com/atherdon I implemented this only in reservation.js because I didn't think it would be useful in the rest of the app at least for the moment... correct me if I'm wrong.

I have one question,Ihave refactored the reservations code to use async/await but I have problems with "next()" callback. Before the refactoring I was calling it at the end of Reservation.observe and it was ok, but now that I am using async/await it throws an error (callback already called and another one that i can't remember now) and I don't know why. I decided remove the call and now all works ok as before... I think one of the problems is that I don't know what is the next() callback for.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChickenKyiv/loopback-tutor-intern-18/issues/2#issuecomment-392380653, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZrDmEortim-ugvHyO-svXJUYgInLSjks5t2yN7gaJpZM4UGNB9 .

atherdon commented 6 years ago

i think i partially get your question. please check groceristar repo - model files with methods. they not well done, i was in rush - but you'll be able to get an idea how to use await inside loopback environment

On 27-May-2018 at 10:06 PM, JorgeRodr wrote:

@atherdon https://github.com/atherdon I implemented this only in reservation.js because I didn't think it would be useful in the rest of the app at least for the moment... correct me if I'm wrong.

I have one question,Ihave refactored the reservations code to use async/await but I have problems with "next()" callback. Before the refactoring I was calling it at the end of Reservation.observe and it was ok, but now that I am using async/await it throws an error (callback already called and another one that i can't remember now) and I don't know why. I decided remove the call and now all works ok as before... I think one of the problems is that I don't know what is the next() callback for.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChickenKyiv/loopback-tutor-intern-18/issues/2#issuecomment-392380653, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZrDmEortim-ugvHyO-svXJUYgInLSjks5t2yN7gaJpZM4UGNB9 .

atherdon commented 6 years ago

btw, main idea of raven is to help you as developer. so if you think resevations only - i'm ok with that. using such kind of tools is just a good rule. it's not required.

JorgeRodr commented 6 years ago

@atherdon I pushed some new code to explain better the issue.

https://github.com/ChickenKyiv/loopback-tutor-intern-18/blob/ccbe7ed4ccb33c31e34be687cf3d505a596b4d2f/server/models/reservation.js#L55

The problem is that I am calling next callback after the sendMail promise. And I get this two erros:

(node:30144) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Callback was already called. warning.js:21 (node:30144) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

If I use normal callbacks instead of async/await promises, I don't get that error, I don't know why.

EDIT:

I have asked on stackoverflow:

https://stackoverflow.com/a/50561944/9114684

It seems that when using async/await calls, next() callback is called automatically. So it was called twice in my code.

Now I'm looking at your code and I can see clearly that you don't call next() when using await. I didn't realize that before :)

Problem solve!

atherdon commented 6 years ago

you just fell into the same trap as i did year ago. sometimes loopback really drives me crazy :) but a lot of things works well from the box, so for now - i cannot see a better nodejs api server. but later i think we'll move forward and replace it :)

atherdon commented 6 years ago

but with this unclear things with next() i think you learn a lot about promises