Tuesday, 15 January 2019

Promise timeouts and avoiding memory leaks

Hey there. So I have an odd scenario in which a package I'm using has a few calls which theoretically could never time out. Unfortunately this package is vital to my business so I can't replace it.​I'd like to be able to create my own way of introducing timeouts so that when I make a call, if it doesn't return in a minute, I can halt execution of that operation. Unfortunately it seems like Promise.race() doesn't seem to actually stop execution of the promise that times out, rather it just executes something else if your timeout promise resolves first.​How would node handle a situation where these calls effectively never returned? Would they eventually be garbage collected somehow or would they built up in memory and cause leaks?

Submitted January 15, 2019 at 09:21PM by RockBand2

No comments:

Post a Comment