Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is nodejs sussceptible to time drift?

I'm troubleshooting an OAuth Authentication issue (invalid_grant) where one of two possible causes is the server's clock being out of sync with NTP. I've ensured the server's clock is synchronized.

Does nodejs instantiate its own clock or reference the system clock?

I expect it would reference the system clock. I only ask because restarting nodejs temporarily fixes the issue (invalid_grant), and I would like to rule out time synchronization.

like image 790
max Avatar asked Nov 01 '13 15:11

max


People also ask

Does NodeJS have a future in 2022?

js, Node. js) will keep their leading positions in app development in 2022. They are robust solutions for building dynamic and single-page web applications.

When NodeJS should not be used?

Avoid Using Node. js: Processing CPU heavy and complex applications: Node. js uses an event-based, non-blocking I/O architecture and only has one CPU – all of that intensive CPU processing would block incoming requests. As a result of the high-end number crunching, the thread might get stuck.

CAN NodeJS handle high traffic?

Since Node. js uses non-blocking IO, the server can handle multiple requests without waiting for each one to complete, which means Node. js can handle a much higher volume of web traffic than other more traditional languages.


1 Answers

There are two way nodejs handle time. using javascript Date or using process.hrtime

Assuming node core uses process.hrtime and you absolutely need to know, I would take a look at the libuv uv_hrtime function which node uses.

Maybe you have found a bug on the uv_hrtime. Whenever I use process.hrtime I never had problem like I did using Date

hope this points you at righ direction.

like image 106
markuz-gj Avatar answered Sep 22 '22 01:09

markuz-gj