With a lot of concurrent requests to metadata service, credentials can fail.

To fix that:
 - add a lock so the metadata service isnt flooded with requests.
 - add setImmediate so IO can still be processed even with a lot of request
   to the metadata service being generated.