[GIS] Feature Layer will not refresh ArcGIS Javascript API

arcgis-javascript-apiarcgis-onlinefeature-layerrefresh

I am trying to integrate live point data (worker locations) from Workforce for ArcGIS into a Javascript web app that I am building.

The layer loads fine and displays on the map properly, it even refreshes as soon as I zoom in or out, but it does not refresh automatically no matter what I try. I have tried using .refreshInterval and when I log the FeatureLayer it has the property set correctly but no refresh happens.

  esriId.registerToken({
    server: 'https://www.arcgis.com/sharing/rest',
    token: sessionStorage.getItem('token'),
    userId: sessionStorage.getItem('user')
  });

  var portal = new Portal({
    authMode: 'immediate'
  });

  portal.load().then(function() {
    var query = {
      query: 'title:workers_ AND access:shared AND type:Feature Service'
    }
    portal.queryItems(query).then(function(queryResult) {
      workers = new FeatureLayer({
        title: 'Workers',
        refreshInterval: 0.1,
        portalItem: queryResult.results[0]
      });
      workers.when(function() {
        workers.makeTemplate();
        console.log(workers);
      });
      map.add(workers);
    });
  });

I have also tried using

setInterval(function() {
    workers.refresh();
    console.log('hi');
}, 6000);

This logs hi every time but still does not refresh the layer.
There are no errors of any kind in the console either. I have tried in both most recent Chrome and most recent Edge.

Does anyone know what the problem is/how to fix it?

Best Answer

This is a bug in the 4.9 JS API. It is in the queue for fixing in 4.10. We failed to implement refresh() using our WebGL-rendered FeatureLayer. It still works if you disable WebGL, but I don't recommend that approach since we plan to only support WebGL rendering in the future. This was oversight on our part, and we plan to resolve it shortly. Sorry about that.