setting [dropdown.selectedIndex] *sometimes* returns SDK errors

Amazing it is working fine most of the times but sometimes returns SDK error:

In a light box, I have an dropdown elements that is connected with a dataset CountryList, which is onloading showing first value in dataset. But I need to set it with certain index with dropdown list populated from dataset so I used following codes on

$w.onReady(async function () {
    $w('#dropdownCountry').selectedIndex = undefined;
    importedObject = await wixWindow.lightbox.getContext();
    const clObject = await wixData.query('countryList').ascending("title").limit(300).find();

    for  (let i= 0 ; i < clObject.totalCount ; i++) {
       if (clObject.items[i].countryCode === importedObject.Country) {
           curCountryIndex = i;
       }
     }
     $w('#dropdownCountry').selectedIndex = curCountryIndex;
});

Most of the time it is working fine, but sometime throwing an error SDK stating as follow

VM24 app.js:25 Wix code SDK error: The value of selectedIndex parameter that is passed to the selectedIndex method cannot be set to the value 164. It must be larger than 0.

164 is value that is found and set to curCountryIndex from clObject under for loop.
Amazing part is that each time, I opened light box through button it works fine but only sometimes (randomly) it throw SDK error even for the same value 164.

I am very much new for javascript or corvid codes, I am sure I am missing something (sort of timeout) but don’t know how to incorporate to catch this error.

Any help or hint would be highly appreciated.