-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Warn on unconfigured cache
#6545
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 644d302:
|
@@ -261,6 +261,21 @@ export class ApolloServerBase< | |||
: noIntro; | |||
} | |||
|
|||
if ( | |||
this.config.nodeEnv === 'production' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!isDev
(requestOptions.persistedQueries === undefined || | ||
(requestOptions.persistedQueries && | ||
!requestOptions.persistedQueries.cache && | ||
!requestOptions.persistedQueries.ttl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ttl not relevant
@@ -261,6 +261,21 @@ export class ApolloServerBase< | |||
: noIntro; | |||
} | |||
|
|||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to right before setting unboundedcache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that it really matters but my idea was it could be nested inside the if (!requestOptions.cache)
below instead of repeating that part of the condition
!requestOptions.persistedQueries.ttl)) | ||
) { | ||
this.logger.warn( | ||
'Apollo Server is running with an unbounded in-memory cache in production. ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Persisted queries are enabled and use an unbounded cache. Your server is vulnerable to denial of service attacks via memory exhaustion. Set cache: 'bounded'
or persistedQueries: false
in your ApolloServer constructor, or see DOCS for other alternatives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, thought i approved before
Issue a warning in production mode if neither the cache nor the APQ cache (persistedQueries.cache) are configured. We've provided a simple path to using a bounded cache via: #6536 The current default for AS3 is an unbounded in memory cache, which is susceptible to a DOS attack since APQs can fill up the server's memory with no limit. This warning provides an actionable recommendation to update their configuration in order to prevent this.
Issue a warning in
production
mode if neither thecache
nor the APQ cache (persistedQueries.cache
) are configured.We've provided a simple path to using a bounded cache via:
#6536
The current default for AS3 is an unbounded in memory cache, which is susceptible to a DOS attack since APQs can fill up the server's memory with no limit. This warning provides an actionable recommendation to update their configuration in order to prevent this.