'Will NodeJS Block Concurrent Calls to Async Function

I have an async function that will cache the result of an expensive port scan for RTSP cameras. Several workers created using setInterval might be calling this function around the same time. I'm wondering will all workers wait until the first promise is resolved and then get the cached result or will each worker start another scan?

/**
 * Get either the cached rstp scan or perform a new one.
 * @param port: port number being scanned
 */
export const getRtspCached = async (port: number): Promise<RstpAddr[]> => {
    const key = port.toString()
    const cached = await rtspCache.getItem<RstpAddr[]>(key)

    if (cached) {
        return cached
    }

    return getRtspForceScan(port)
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source