Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource activeRefresh behave as a very short cache, even if ketting use the NeverCache implementation #401

Closed
hugothomas opened this issue Aug 17, 2021 · 0 comments · Fixed by #402

Comments

@hugothomas
Copy link
Contributor

hugothomas commented Aug 17, 2021

Hello,

We are using Prefer header.

Our server is configured to return hal-forms.
On a prefer: return=minimal request, a partial representation is returned (only the _links and the _templates), otherwise the full representation (_links _templates _embedded) will be returned.

My ketting is using the NeverCache implementation.

By doing this :

await Promise.all([
    resource.get({headers: {'Prefer': 'return=minimal'}}),
    resource.followAll('item')
]);

I'm expecting to get two HTTP responses,

  • for the first call :
{
  "_links": {
    "self": {
      "href": "selfLink"
    }
  },
  "_templates": {
    "default": {
      "method": "post",
      "properties": []
    }
  }
}
  • for the second one :
{
  "_embedded": {
    "item": [
      {
        "name": "toto",
        "_links": {
          "self": {
            "href": "selfLink"
          }
        }
      },
      {
        "name": "titi",
        "_links": {
          "self": {
            "href": "selfLink"
          }
        }
      }
    ]
  },
  "_links": {
    "self": {
      "href": "selfLink"
    }
  },
  "_templates": {
    "default": {
      "method": "post",
      "properties": []
    }
  }
}

But i'm only receiving the first response, only once. The second call isn't performed.

By doing two distinct calls :

await resource.get({headers: {'Prefer': 'return=minimal'}});
await resource.followAll('item');

I'm getting two distinct responses as expected.

According to my research, my issue is caused by Resource.activeRefresh

I'm suggesting to :

  • remove activeRefresh behavior. Because by returning a Promise we will not have concurrency problems (maybe I'm missing something).

OR

  • add a parameter in the Ketting configuration to bypass the activeRefresh behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant