Hooks code is not working in live site..and its working in the preview mode...help me to solve this problem..

import wixData from 'wix-data';

export function searchforduplicates(collection,field,item) {
 return wixData.query('emailtestcollection').eq(field,item[field]).find().then((results) => {
 return results.items.length
    }).catch((err) => {
 let errorMsg=err
        console.log(err)
    })

 
}

export async function emailtestcollection_beforeInsert(item,context) {
 return searchforduplicates(context.collectionName,"email",item).then((res) => {
 if(res>0) {
 return Promise.reject('this item is already existed')
                }
 return item 
 
                })
}