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(gatsby): open lmdb instances in writeable locations in generated ssr/dsg function #38631

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/gatsby/src/utils/cache-lmdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const cacheDbFile =
}`
: `caches-lmdb`

const dbPath = path.join(process.cwd(), `.cache/${cacheDbFile}`)
const dbPath = path.join(
global.__GATSBY?.root || process.cwd(),
`.cache/${cacheDbFile}`
)

function getAlreadyOpenedStore(): RootDatabase | undefined {
if (!globalThis.__GATSBY_OPEN_ROOT_LMDBS) {
Expand Down
10 changes: 8 additions & 2 deletions packages/gatsby/src/utils/page-ssr-module/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ function setupFsWrapper(): string {
} catch (e) {
// we are in a read-only filesystem, so we need to use a temp dir

const TEMP_CACHE_DIR = path.join(tmpdir(), `gatsby`, `.cache`)
const TEMP_DIR = path.join(tmpdir(), `gatsby`)
const TEMP_CACHE_DIR = path.join(TEMP_DIR, `.cache`)

global.__GATSBY = {
root: TEMP_DIR,
buildId: ``,
}

// TODO: don't hardcode this
const cacheDir = `/var/task/.cache`
Expand Down Expand Up @@ -148,8 +154,8 @@ async function getEngine(): Promise<GraphQLEngineType> {
reject(error)
})
})
console.log(`Downloaded datastore from CDN`)
}
console.log(`Downloaded datastore from CDN`)
Comment on lines +157 to -152
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated to rest of changes, just noticed this was logged even if LMDB wasn't excluded from the bundle (so when it shouldn't be logged)


const graphqlEngine = new GraphQLEngine({
dbPath,
Expand Down