Netflix/falcor

Getting MaxRetryExceededError when using `$expires`

asyncanup opened this issue · 1 comments

snippet to reproduce behavior

var falcor = require('..');
var datasource = falcor({
    cache: {
        todos: [
            {
                name: { $type: 'atom', value: 'name value', $expires: -3 },
                done: false
            },
            {
                name: 'withdraw money from ATM',
                done: true
            }
        ]
    }}).asDataSource();
var model = falcor({ source: datasource });

// const chooseKeys = (k, v) => k.startsWith('$') ? undefined : v;
const logCache = () => {
  console.log(model._root.cache.todos[0].name);
};

model.get('todos[0].name').then(result => {
  console.log('result');
  console.log(result);
  
  logCache();
  setTimeout(() => {
    model.withoutDataSource().get('todos[0].name').subscribe(console.log);
  }, 100);
}, console.error);

output:

{ MaxRetryExceededError: The allowed number of retries have been exceeded.
    at getRequestCycle (/Users/abishnoi/code/falcor/lib/response/get/getRequestCycle.js:26:26)
    at /Users/abishnoi/code/falcor/lib/response/get/getRequestCycle.js:93:21
    at refCountCallback (/Users/abishnoi/code/falcor/lib/request/RequestQueueV2.js:117:17)
    at /Users/abishnoi/code/falcor/lib/request/GetRequestV2.js:120:33
    at Object.onCompleted (/Users/abishnoi/code/falcor/lib/request/flushGetRequest.js:86:13)
    at ModelResponseObserver.onCompleted (/Users/abishnoi/code/falcor/lib/response/ModelResponseObserver.js:64:28)
    at checkCacheAndReport (/Users/abishnoi/code/falcor/lib/response/get/checkCacheAndReport.js:94:22)
    at GetResponse._subscribe (/Users/abishnoi/code/falcor/lib/response/get/GetResponse.js:61:19)
    at GetResponse.subscribe (/Users/abishnoi/code/falcor/lib/response/ModelResponse.js:86:29)
    at flushGetRequest (/Users/abishnoi/code/falcor/lib/request/flushGetRequest.js:81:9)
  name: 'MaxRetryExceededError',
  missingOptimizedPaths: [ [ 'todos', 0, 'name' ] ] }

Same issue when using $expires: 0, other small negative numbers (> -10), or positive numbers smaller than Date.now() + 10

I thought we had fixed expires:0 behavior with #905 so would be worth getting our heads around how the above test case differs from the tests added for the above pull request (does this impact the 80% path or not), and would also be useful to determine whether or not the small value (negative or positive) behavior is a regression, or has existed since before the above pull request was merged.