-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
On calling .scroll() or .count() more than 1 time in a loop, I get this error on the second call:
{ "name": "SocketError", "code": "UND_ERR_SOCKET", "socket": { "localAddress": "192.168.0.68", "localPort": 50707, "remoteAddress": "192.168.0.160", "remotePort": 6333, "remoteFamily": "IPv4", "bytesWritten": 920, "bytesRead": 328 } }
with that code:
async process(response) {
const cache = {}
const filtered = []
for (const message of response) {
const formattedDate = moment(message.date).format('YYYY-MM-DD')
if (!(formattedDate in cache)) {
cache[formattedDate] = await QdrantService.exists(formattedDate, 'chat')
}
if (!cache[formattedDate]) {
filtered.push(message)
} else {
logger.info(`Chat for ${formattedDate} already exists in Qdrant, skipping...`)
}
}
response = filtered
}
async function exists(date, type) {
try {
const start = new Date(date + "T00:00:00Z").toISOString()
const end = new Date(date + "T23:59:59Z").toISOString()
const { count } = await qdrantClient.count(config.qdrant.collection, {
exact: false,
filter: {
must: [
{
key: "type",
match: {value: type}
},
{
key: "date",
range: {
gte: start,
lte: end
}
}
]
}
})
return count > 0
} catch (e) {
logger.error(`Error in exists() for ${date} - ${type}: ${e.message}`)
}
}but it work if I add this at the start of the "exists" function
await new Promise(r => setTimeout(r, 200))IvanPleshkov
Metadata
Metadata
Assignees
Labels
No labels