Uncaught (in promise) TypeError: google.maps.importLibrary is not a function – Map not loading

Using google maps API, map seems to load 20% of the time. Currently getting the above error. The following is my php:

<script>
        async function initMap() {
            const { Map, InfoWindow } = await google.maps.importLibrary("maps");
            const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary(
                "marker",
            );
        }
        document.addEventListener('DOMContentLoaded', (event) => {
                initMap();
        });
</script>

<div class="search">
        <input id="autocomplete" placeholder="Enter address, city, or zip/postal code" type="text">
</div>
<div id="loadMap" style="height: 600px; width: 100%;"></div>

<script src="https://maps.google.com/maps/api/js?v=weekly&key=KEY&libraries=places&loading=async&solution_channel=GMP_guides_locatorplus_v2_a"></script>

Expecting the map to load 100% of the time.