If a feature layer is created with a definition expression and then gets set to null it throws an error and essentially snapshots the max number features the service supports in one request and that's all the features which are displayed with no more requests on extent change. Based on the error it looks like the creating the layer with a definition expression does a snapshot thing instead of on demand.
If created without a definition expression, the layer can be set to null or any other expression and works fine.
Not sure if this is a bug or if there is another way to clear the definition expression to avoid this error. I don't see any prop like 3.x mode.
<SPAN class="comment token">// EXAMPLE ONE</SPAN>
<SPAN class="comment token">// create layer with definitionExpression</SPAN>
<SPAN class="keyword token">const</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fservice%2Furl" target="_blank">https://service/url</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
definitionExpression<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'ACTIVE = 1'</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// first n number of features shown and throws error</SPAN>
<SPAN class="comment token">// [esri.layers.graphics.controllers.SnapshotController] Feature limit exceeded on layer " Permits ". Not all features are shown.</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="string token">'ACTIVE = 1'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// works as expected</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="string token">'ACTIVE = 0'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// works as expected</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// same error as above</SPAN>
<SPAN class="comment token">//EXAMPLE TWO</SPAN>
<SPAN class="comment token">// create layer without definitionExpression</SPAN>
<SPAN class="keyword token">const</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fservice%2Furl" target="_blank">https://service/url</A><SPAN>'</SPAN></SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// works as expected</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="string token">'ACTIVE = 1'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// works as expected</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// works as expected</SPAN>
layer<SPAN class="punctuation token">.</SPAN>definitionExpression <SPAN class="operator token">=</SPAN> <SPAN class="string token">'ACTIVE = 0'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// works as expected</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>