Select to view content in your preferred language

Search Widget console errors featureResult undefined

433
1
Jump to solution
01-12-2023 01:39 PM
GregoryBologna
Frequent Contributor

The Search Widget occassionally returns this error to Chrome console on suggest-complete. Happens on first use but works as expected afterwards. This was reported in an earlier version here.

https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-console-errors-show... 

 

Click in search field.

GregoryBologna_1-1673559275580.png

suggest-complete
 

GregoryBologna_0-1673559256119.png

Console message

[esri.widgets.Search.SearchViewModel] TypeError: Cannot read properties of undefined (reading 'featureResult')

at q (https://js.arcgis.com/4.25/:43:249) {stack: 'TypeError: Cannot read properties of undefine… at q (https://js.arcgis.com/4.25/:43:249)', message: 'Cannot read properties of undefined (reading 'featureResult')'}

arg1:
TypeError: Cannot read properties of undefined (reading 'featureResult')\n at a.parsePBFFeatureQuery (https://js.arcgis.com/4.25/:2160:431)\n at Module.<anonymous> (https://js.arcgis.com/4.25/:2140:466)\n at Generator.next (<anonymous>)\n at d (https://js.arcgis.com/4.25/:38:488)\n at q (https://js.arcgis.com/4.25/:43:249) {stack: 'TypeError: Cannot read properties of undefine… at q (https://js.arcgis.com/4.25/:43:249)', message: 'Cannot read properties of undefined (reading 'featureResult')'}
message:
'Cannot read properties of undefined (reading 'featureResult')'
stack:
'TypeError: Cannot read properties of undefined (reading 'featureResult')\n at a.parsePBFFeatureQuery (https://js.arcgis.com/4.25/:2160:431)\n at Module.<anonymous> (https://js.arcgis.com/4.25/:2140:466)\n at Generator.next (<anonymous>)\n at d (https://js.arcgis.com/4.25/:38:488)\n at q (https://js.arcgis.com/4.25/:43:249)'
[[Prototype]]:
Error
m._consoleWriter @ js.arcgis.com/4.25/(index):150:331

0 Kudos
1 Solution

Accepted Solutions
GregoryBologna
Frequent Contributor

The location of the error is on line 1 below.

 

const queryFeatureLayer = new FeatureLayer({ params here... }
const queryObject = queryFeatureLayer.createQuery();
set the queryObject  params

run query

1. queryFeatureLayer.queryFeatures(queryObject)
2.   .then((layerView) =>  { ... }
 

My guess is that the server responded with zero results or did not complete the query at all.

Running the query a second time often works, so my workaround is to run again.

 

if(error.message.indexOf('featureResult') > -1) {

                  setTimeout(() => {
                    run the query again
                  }, 350);
 

View solution in original post

0 Kudos
1 Reply
GregoryBologna
Frequent Contributor

The location of the error is on line 1 below.

 

const queryFeatureLayer = new FeatureLayer({ params here... }
const queryObject = queryFeatureLayer.createQuery();
set the queryObject  params

run query

1. queryFeatureLayer.queryFeatures(queryObject)
2.   .then((layerView) =>  { ... }
 

My guess is that the server responded with zero results or did not complete the query at all.

Running the query a second time often works, so my workaround is to run again.

 

if(error.message.indexOf('featureResult') > -1) {

                  setTimeout(() => {
                    run the query again
                  }, 350);
 
0 Kudos