Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: gatsby@3.14.3
Choose a base ref
...
head repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: gatsby@3.14.4
Choose a head ref
  • 4 commits
  • 6 files changed
  • 3 contributors

Commits on Oct 18, 2021

  1. fix(gatsby-dev-cli): resolve correct versions of packages with unpkg (#…

    …33551) (#33570)
    
    * fix(gatsby-dev-cli): resolve correct versions of packages with unpkg
    
    * a bit more details in case of errors
    
    * defaults for deps
    
    (cherry picked from commit 31d5a5e)
    
    Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
    GatsbyJS Bot and vladar authored Oct 18, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    016bab7 View commit details
  2. chore(release): Publish

     - gatsby-dev-cli@3.14.1
    vladar committed Oct 18, 2021
    Copy the full SHA
    c692e1f View commit details

Commits on Oct 22, 2021

  1. fix(gatsby): use lmdb.removeSync so getNode can't return deleted nodes (

    #33554) (#33633)
    
    Co-authored-by: Ward Peeters <ward@coding-tech.com>
    (cherry picked from commit 98a843c)
    
    # Conflicts:
    #	packages/gatsby/src/datastore/lmdb/lmdb-datastore.ts
    
    Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
    vladar and KyleAMathews authored Oct 22, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d4cf891 View commit details
  2. chore(release): Publish

     - gatsby-admin@0.24.4
     - gatsby@3.14.4
    vladar committed Oct 22, 2021
    Copy the full SHA
    fdf616c View commit details
4 changes: 2 additions & 2 deletions packages/gatsby-admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-admin",
"version": "0.24.3",
"version": "0.24.4",
"main": "index.js",
"author": "Max Stoiber",
"license": "MIT",
@@ -29,7 +29,7 @@
"@typescript-eslint/parser": "^4.29.3",
"csstype": "^2.6.17",
"formik": "^2.2.9",
"gatsby": "^3.14.3",
"gatsby": "^3.14.4",
"gatsby-interface": "^0.0.244",
"gatsby-plugin-typescript": "^3.14.0",
"gatsby-plugin-webfonts": "^1.1.4",
2 changes: 1 addition & 1 deletion packages/gatsby-dev-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-dev-cli",
"description": "CLI helpers for contributors working on Gatsby",
"version": "3.14.0",
"version": "3.14.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby-dev": "./dist/index.js"
21 changes: 15 additions & 6 deletions packages/gatsby-dev-cli/src/utils/check-deps-changes.js
Original file line number Diff line number Diff line change
@@ -60,16 +60,16 @@ exports.checkDepsChanges = async ({
// this allow us to not publish to local repository
// and save some time/work
try {
const response = await got(
`https://unpkg.com/${packageName}/package.json`
)
const version = getPackageVersion(packageName)
const url = `https://unpkg.com/${packageName}@${version}/package.json`
const response = await got(url)
if (response?.statusCode !== 200) {
throw new Error(`No response or non 200 code`)
throw new Error(`No response or non 200 code for ${url}`)
}
localPKGjson = JSON.parse(response.body)
} catch {
} catch (e) {
console.log(
`'${packageName}' doesn't seem to be installed and is not published on NPM.`
`'${packageName}' doesn't seem to be installed and is not published on NPM. Error: ${e.message}`
)
return {
didDepsChanged: true,
@@ -182,3 +182,12 @@ exports.checkDepsChanges = async ({
packageNotInstalled,
}
}

function getPackageVersion(packageName) {
const projectPackageJson = JSON.parse(
fs.readFileSync(`./package.json`, `utf-8`)
)
const { dependencies = {}, devDependencies = {} } = projectPackageJson
const version = dependencies[packageName] || devDependencies[packageName]
return version || `latest`
}
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby",
"description": "Blazing fast modern site generator for React",
"version": "3.14.3",
"version": "3.14.4",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "./cli.js"
49 changes: 35 additions & 14 deletions packages/gatsby/src/datastore/lmdb/lmdb-datastore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RootDatabase, open } from "lmdb-store"
import { RootDatabase, open, ArrayLikeIterable } from "lmdb-store"
// import { performance } from "perf_hooks"
import { ActionsUnion, IGatsbyNode } from "../../redux/types"
import { updateNodes } from "./updates/nodes"
@@ -27,6 +27,8 @@ const lmdbDatastore = {
getNodesByType,
}

const preSyncDeletedNodeIdsCache = new Set()

function getDefaultDbPath(): string {
const dbFileName =
process.env.NODE_ENV === `test`
@@ -122,10 +124,8 @@ function iterateNodes(): GatsbyIterable<IGatsbyNode> {
return new GatsbyIterable(
nodesDb
.getKeys({ snapshot: false })
.map(
nodeId => (typeof nodeId === `string` ? getNode(nodeId) : undefined)!
)
.filter(Boolean)
.map(nodeId => (typeof nodeId === `string` ? getNode(nodeId) : undefined))
.filter(Boolean) as ArrayLikeIterable<IGatsbyNode>
)
}

@@ -134,13 +134,16 @@ function iterateNodesByType(type: string): GatsbyIterable<IGatsbyNode> {
return new GatsbyIterable(
nodesByType
.getValues(type)
.map(nodeId => getNode(nodeId)!)
.filter(Boolean)
.map(nodeId => getNode(nodeId))
.filter(Boolean) as ArrayLikeIterable<IGatsbyNode>
)
}

function getNode(id: string): IGatsbyNode | undefined {
if (!id) return undefined
if (!id || preSyncDeletedNodeIdsCache.has(id)) {
return undefined
}

const { nodes } = getDatabases()
return nodes.get(id)
}
@@ -151,9 +154,11 @@ function getTypes(): Array<string> {

function countNodes(typeName?: string): number {
if (!typeName) {
const stats = getDatabases().nodes.getStats()
// @ts-ignore
return Number(stats.entryCount || 0) // FIXME: add -1 when restoring shared structures key
const stats = getDatabases().nodes.getStats() as { entryCount: number }
return Math.max(
Number(stats.entryCount) - preSyncDeletedNodeIdsCache.size,
0
) // FIXME: add -1 when restoring shared structures key
}

const { nodesByType } = getDatabases()
@@ -192,14 +197,30 @@ function updateDataStore(action: ActionsUnion): void {
break
}
case `CREATE_NODE`:
case `DELETE_NODE`:
case `ADD_FIELD_TO_NODE`:
case `ADD_CHILD_NODE_TO_PARENT_NODE`:
case `DELETE_NODE`: {
case `ADD_CHILD_NODE_TO_PARENT_NODE`: {
const dbs = getDatabases()
lastOperationPromise = Promise.all([
const operationPromise = Promise.all([
updateNodes(dbs.nodes, action),
updateNodesByType(dbs.nodesByType, action),
])
lastOperationPromise = operationPromise

// if create is used in the same transaction as delete we should remove it from cache
if (action.type === `CREATE_NODE`) {
preSyncDeletedNodeIdsCache.delete(action.payload.id)
}

if (action.type === `DELETE_NODE` && action.payload?.id) {
preSyncDeletedNodeIdsCache.add(action.payload.id)
operationPromise.then(() => {
// only clear if no other operations have been done in the meantime
if (lastOperationPromise === operationPromise) {
preSyncDeletedNodeIdsCache.clear()
}
})
}
}
}
}
1 change: 1 addition & 0 deletions packages/gatsby/src/datastore/lmdb/updates/nodes.ts
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ export function updateNodes(
if (action.payload) {
return nodesDb.remove(action.payload.id)
}

return false
}
}