Comments (4)
I can confirm that we see the same behavior.
from datasource-rest.
Do you have the same behavior when you're not using cachecontrol?
from datasource-rest.
@michielmulders Yes same behavior.
from datasource-rest.
I'd love to investigate this now that we are maintaining RESTDataSource again, but the original report isn't a complete reproduction recipe that allows us to try it out without a bunch of creative choices to try to reproduce what you were seeing. The code snippets are incomplete, and also it doesn't say what kind of operations you run (the same operation over and over? different ones?)
To be honest, I would expect exactly the opposite issue here: back in 2020 when you filed this, the default KeyValueCache used by ApolloServer had an unbounded size, so without any TTL I would expect a leak, where as with a TTL I would expect no leak. Looking into it further, it looks like lru-cache@6
(which powered InMemoryLRUCache back then) doesn't have any special handling of a ttl
of -1 (which we convert to a maxAge of -1000) and this is interpreted not as "there is no TTL, keep forever" but "it's already out of date, drop as soon as you bother to check". So it's not too surprising that ttl: 1
uses more memory than ttl: -1
.
Additionally, the lru-cache
library does not actually active purge things that are out of date by default. It's just that if you try to fetch something that is out of date, it will get dropped. The older lru-cache@6 version used when this was filed had no way of automatically dropping old data other than manually calling prune()
every so often. The newer version used by today's InMemoryLRUCache does have a ttlAutopurge
flag, though it's not recommended by the author. More importantly, the newer version of lru-cache
doesn't let you configure an unbounded cache, and so the current version of InMemoryLRUCache is always bounded.
So basically, I think everything you're seeing here is addressed by the fact that the current InMemoryLRUCache (in @apollo/utils.keyvaluecache
) is backed by lru-cache v7, which is always a bounded cache.
If you're able to reproduce this with the latest versions of RESTDataSource (in @apollo/datasource-rest
, not apollo-dataousrce-rest
) we can reopen (ideally with a full self-contained reproduction!).
from datasource-rest.
Related Issues (20)
- Next release of package @apollo/datasource-rest HOT 2
- Type signature for params is too narrow HOT 4
- RESTDataSource’s willSendRequest parameter changes HOT 2
- Get/Set HTTP Status? HOT 1
- willSendRequest this.context does not exist on xxxxDataSource HOT 1
- `didReceiveResponse` hook no longer available, blocking Apollo v4 upgrade HOT 6
- Errors stop getting sent to client if the override of fetch includes a catch callback HOT 2
- Configuring external caching in Apollo v4 HOT 3
- Question related to changes in request parameters HOT 2
- RESTDataSource implementation issue with `willSendRequest` & `@apollo/utils.withrequired` is a devDependency HOT 4
- Apollo Datasource adds content-type: header when Content-Type (case sensitive) header is set HOT 3
- RESTDataSource no longer have access to all datasources through context HOT 2
- Document `contextValue` recipe for circular references in context object
- Posting FormData as body (for file uploads) not possible anymore HOT 7
- Forward all cache options to key value cache HOT 6
- Unable to connect to Localhost server HOT 1
- @apollo/datasource-rest willSendRequest param type missing `agent` HOT 7
- [apollo-datasource-rest] Handling 404 errors HOT 2
- Feature request - be able to tell if API was resolved by memory, cache, or source HOT 3
- RESTDataSource - body based cacheKeyFor POST request HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasource-rest.