node js variables not giving right values on concurrent events

25
June 19, 2019, at 4:20 PM

So I am using nodejs and using redis pubsub mechanism in that . I have subscribed for a particular topic on redis , which when triggered calls a function. When there are two events (say Event-A and Event-B) on function call I can see data of Event-A being saved where Event-B data should have been saved

I thought global variables would have had been an issue , so I made them local inside the function , still I am getting the same issue (when two subscription Event triggers almost simultaneously)

chtr = new eventTracker({
    timestamp: timestamp,
    loc_lat: json_data['lat'],
    loc_lon:json_data['lng'],
    imei:json_data['imei'].toString(),
    source:e_source
})
chtr.save().then(()=>{
    send_notification(obj);
    save_notificiation(obj)
})

Event A say has lat long :- 1 , 1

Event B has lat , long :- 2 ,2 .

So for both events that is being saved in mongodb , I am getting values of Event B i.e 2 ,2 . Also the notification that is to be sent (sent notification function)

READ ALSO
setInterval() is different between browser and Node

setInterval() is different between browser and Node

The global methods setInterval and setTimeout are different between browser (window) and NodeJS (global)The behavior is quite the same

28
How to use node js child process for installed cli apps?

How to use node js child process for installed cli apps?

I have a CLI installed appWhenever I try to use these processes on a child-process, it says that those commands are not found

29
Debian, node installation, release file error

Debian, node installation, release file error

I have a question regarding Debian and node installation

57
Ng serve stops working everyday again. Requesting localhost wont open my project, but download a random file i never saw before

Ng serve stops working everyday again. Requesting localhost wont open my project, but download a random file i never saw before

Everyday I start my computer, open git bash and type ng serveI go to localhost:4200 (also tried alternative ports) trying to get to my project, but out of nothing there is no redirect, its just downloading a random file and thats it

27