Skip to content

UND_ERR_SOCKET on second callΒ #121

@lluisd

Description

@lluisd

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))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions