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

fix: expose ".del" function on lmdb cache #32459

Merged
merged 4 commits into from Jul 21, 2021
Merged

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Jul 21, 2021

Description

Introduction of lmdb implementation of cache (passed to plugins) is missing .cache internal cache being exposed (as "legacy" cache does). This cause gatsby-plugin-sharp that want to use .del on that internal cache instance to crash in gatsby develop.

This PR does few things:
a) adds compat mode to lmdb cache implementation (add .cache property that is just reference to itself)
b) adds .del method on public interface (and implement it in both legacy cache and lmdb cache)
c) future proofs gatsby-plugin-sharp to use public .del if available (ideally we remove access to internal cache implementation in v4)

Related Issues

Fixes #32445

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 21, 2021
@pieh pieh changed the title Fix/lmdb dev sharp cache fix: expose ".del" function on lmdb cache Jul 21, 2021
@LekoArts LekoArts added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 21, 2021
@vladar
Copy link
Contributor

vladar commented Jul 21, 2021

Probably also need to update this dummy one:

const getUninitializedCache = plugin => {
const message =
`Usage of "cache" instance in "onPreInit" API is not supported as ` +
`this API runs before cache initialization` +
(plugin && plugin !== `default-site-plugin` ? ` (called in ${plugin})` : ``)
return {
// GatsbyCache
async get() {
throw new Error(message)
},
async set() {
throw new Error(message)
},
}
}

@pieh
Copy link
Contributor Author

pieh commented Jul 21, 2021

Probably also need to update this dummy one:

const getUninitializedCache = plugin => {
const message =
`Usage of "cache" instance in "onPreInit" API is not supported as ` +
`this API runs before cache initialization` +
(plugin && plugin !== `default-site-plugin` ? ` (called in ${plugin})` : ``)
return {
// GatsbyCache
async get() {
throw new Error(message)
},
async set() {
throw new Error(message)
},
}
}

Added in 229a523

@LekoArts LekoArts added this to To cherry-pick in V3 Release Hotfixes via automation Jul 21, 2021
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@pieh pieh merged commit e1a1396 into master Jul 21, 2021
@pieh pieh deleted the fix/lmdb-dev-sharp-cache branch July 21, 2021 12:48
LekoArts pushed a commit that referenced this pull request Jul 21, 2021
* expose '.del' method on cache instances, mark exposing internal cache instance to be removed in v4

* make gatsby-plugin-sharp work with legacy cache del way and new way with properly exposed del method

* add .del method to ts typings

* add .del method to dummy cache (for onPreInit lifecycle)

(cherry picked from commit e1a1396)
@LekoArts LekoArts moved this from To cherry-pick to Backport PR opened in V3 Release Hotfixes Jul 21, 2021
LekoArts pushed a commit that referenced this pull request Jul 21, 2021
* expose '.del' method on cache instances, mark exposing internal cache instance to be removed in v4

* make gatsby-plugin-sharp work with legacy cache del way and new way with properly exposed del method

* add .del method to ts typings

* add .del method to dummy cache (for onPreInit lifecycle)

(cherry picked from commit e1a1396)

Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
@LekoArts LekoArts moved this from Backport PR opened to Backported in V3 Release Hotfixes Jul 21, 2021
@LekoArts LekoArts moved this from Backported to Published in V3 Release Hotfixes Jul 21, 2021
@LekoArts
Copy link
Contributor

Fixed in gatsby-plugin-sharp@3.10.2 and gatsby@3.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Gatsby Plugin Sharp error after upgrading to v3.10.0
3 participants