CustomSelector results with unique ID error

Enonic version: 7.8.2
macOS: 12.0.1
Content Studio: 4.0.2

I have a CustomSelector that gets results from an external API. Results are returning correct, with no duplicate IDs (we’ve added safeguards for this in the code). With each new tap and depending on how fast I’m typing (filling in or removing characters), it seems that the CustomSelector doesn’t understand the exchange of results and sometimes returns a duplicate ID error.
Please, check my record:
customSelector_id_error

Here is a part of my code that creates the service return:

GetSnowstormUseCase.prototype.execute = function execute (text, conceptRefset) {
	const self = this

	if (text) {
		const response = self.Snowstorm.queryInSnowstormAPIRefset(text, conceptRefset)
		const items = self.Collections.forceArray(response && response.items)
		const hits = []

		items.forEach(item => {
			if (item.concept) {
				if (!hits.some(el => el.id === item.concept.conceptId)) {
					if (item.concept && item.concept.fsn && item.concept.pt) {
						hits.push({
							id: item.concept.conceptId,
							description: `FSN Term: ${item.concept.fsn.term}; SCTID: ${item.concept.conceptId}`,
							displayName: item.concept.pt.term
						})
					}
				}
			}
		})

		return {
			hits: hits,
			total: hits.length,
			count: hits.length
		}
	} else {
		return {
			hits: [],
			total: 0,
			count: 0
		}
	}
}

Let me know if I can help with any more information.

3 Likes

This has been reported multiple times but we never managed to reproduce it until today, see description in the issue we registered. Seems like this happens when responses from several pending requests come at the same time.

We’ll start looking at this asap.

2 Likes

This should now be fixed in the latest Content Studio 4.0.3 (requires XP 7.8.2 or higher).

1 Like

Hi @ase.

Unfortunately, even with the new version, we are still getting the same problem (less, but it still happens).
I spent some time testing and I have a guess on when this is happening.
If we have two identical requests pending at the same time, the error will occur when the second one was complete.

Please, look:
image

Error-contentstudio

I have tested it in two different projects and had the same behavior for both.