datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 51 forks source link

The plugin "gatsby-source-datocms" deleted a node of a type owned by another plugin. #112

Closed Masadow closed 4 years ago

Masadow commented 4 years ago

Hi,

After upgrading Gatsby to version 2.22.10 and using this plugin on version 2.2.4, whenever I try to build my app without removing the .cache/datocms-assets folder, build fails with the following stack trace:

  Error: The plugin "gatsby-source-datocms" deleted a node of a type owned by   another plugin.
            The node type "DatoCmsField" is owned by "undefined".
            The node object passed to "deleteNode":
            {
      "id": "DatoCmsField-677586",
      "parent": null,
      "children": [],
      "internal": {
          "type": "DatoCmsField",
          "contentDigest": "d8805d2fdf57b367fb9b78ab4d884bd0",
          "counter": 246,
          "owner": "gatsby-source-datocms"
      },
      "label": "Title",
      "fieldType": "string",
      "apiKey": "title",
      "localized": true,
      "validators": {
          "required": {}
      },
      "position": 1,
      "appeareance": {
          "addons": [],
          "editor": "single_line",
          "parameters": {
              "heading": false
          }
      },
      "defaultValue": {
          "fr": null,
          "en": null
      },
      "originalId": "677586"
  }
            The plugin deleting the node:
            {
      "resolve": "/Users/jimmy/projects/ector-front/node_modules/gatsby-sourc  e-datocms",
      "id": "408ce464-e94c-5d22-a673-28525d31a655",
      "name": "gatsby-source-datocms",
      "version": "2.2.4",
      "pluginOptions": {
          "plugins": [],
          "apiToken": "-------",
          "apiUrl": "https://site-api.datocms.com",
          "disableLiveReload": true,
          "previewMode": true
      },
      "nodeAPIs": [
          "createSchemaCustomization",
          "sourceNodes"
      ],
      "browserAPIs": [],
      "ssrAPIs": [],
      "pluginFilepath": "/Users/jimmy/projects/ector-front/node_modules/gatsb  y-source-datocms"
  }

  - public.js:485 actions.deleteNode
    [ector-front]/[gatsby]/dist/redux/actions/public.js:485:70

  - redux.js:483 
    [ector-front]/[redux]/lib/redux.js:483:35

  - api-runner-node.js:90 Object.doubleBoundActionCreators.<computed> [as del    eteNode]
    [ector-front]/[gatsby]/dist/utils/api-runner-node.js:90:20

  - destroyEntityNode.js:44 
    [ector-front]/[gatsby-source-datocms]/hooks/sourceNodes/destroyEntityNode    .js:44:23

  - Array.map

  - destroyEntityNode.js:40 module.exports
    [ector-front]/[gatsby-source-datocms]/hooks/sourceNodes/destroyEntityNode    .js:40:19

  - index.js:158 
    [ector-front]/[gatsby-source-datocms]/hooks/sourceNodes/index.js:158:15

  - Array.forEach

  - EntitiesRepo.js:130 
    [ector-front]/[datocms-client]/lib/local/EntitiesRepo.js:130:25

  - Array.forEach

  - EntitiesRepo.js:129 EntitiesRepo.destroyEntities
    [ector-front]/[datocms-client]/lib/local/EntitiesRepo.js:129:29

  - EntitiesRepo.js:90 
    [ector-front]/[datocms-client]/lib/local/EntitiesRepo.js:90:18

  - Array.forEach

  - EntitiesRepo.js:88 EntitiesRepo.destroyAllEntities
    [ector-front]/[datocms-client]/lib/local/EntitiesRepo.js:88:56

  - Loader.js:93 
    [ector-front]/[datocms-client]/lib/local/Loader.js:93:29
PHironaka commented 4 years ago

experiencing the same problem.

shansmith01 commented 4 years ago

I Had the same issue. Turning off the gastby incremental builds in Netlify seems to have fixed the issue

Masadow commented 4 years ago

@shansmith01 maybe Netlify does a gatsby clean before building ?

I'm building with CI tools and not using incremental builds. Even building on my computer locally produce the same result.

dante-blitz commented 4 years ago

@shansmith01 maybe Netlify does a gatsby clean before building ?

I'm building with CI tools and not using incremental builds. Even building on my computer locally produce the same result.

I'm having the same issue locally and on CircleCI builds as well. If I cancel the develop process locally and retry I do not get any errors.

PHironaka commented 4 years ago

@shansmith01 @Masadow @dante-blitz I think this issue is related to incremental builds, it was working for me momentarily in Netlify. I manage my content in DatoCMS which is supposed to be supported by incremental builds.

matjack1 commented 4 years ago

Hello, sorry but I'm not able to reproduce your issue locally.

If you can reproduce locally can you please provide me the exact steps that you are taking together with the versions of Gatsby and our source plugin? Thank you!

PHironaka commented 4 years ago

@matjack1 I am using version 2.2.4 of gatsby-source-datocms with gatsby version 2.4.2

When I rebuild my site locally and push to netlify, it works. When I push a content update in DatoCMS w/incremental builds implemented, it fails.

matjack1 commented 4 years ago

@PHironaka by incremental builds you mean the Gatsby cache plugin in Netlify?

PHironaka commented 4 years ago

@matjack1 yes

stippets commented 4 years ago

I'm also having the same issue. I can reproduce locally by simply running the build command twice. However, if I delete my .cache folder it seems to work fine. The error happens if I run a build locally, then try to run another build without deleting the .cache folder.

Masadow commented 4 years ago

Hi @matjack1 , this issue is not related to incremental build for me as I don't use it.

However, what seems to be causing the issue is to have unpublished items in dato but still building fetching this data (for staging env for instance)

matjack1 commented 4 years ago

Thank you very much for the last hint @Masadow I've reproduced with the draft/published in place. We are going to fix it as soon as possible!

matjack1 commented 4 years ago

Sorry can you please try a yarn upgrade/npm upgrade?

I've done that and it fixed all my issues :(

It might be a dependency below the surface causing problems? Can anyone confirm please?

PHironaka commented 4 years ago

@matjack1 thanks for helping. I deleted my node modules and ran npm upgrade, unfortunately still getting the same error message. I also tried deleted my unpublished drafts, cleared cache on Netlify which produced a successful published build. Then tried making another content update in Dato which produced the failed build.

gastongarcia commented 4 years ago

I've been having the same issue since yesterday. I can do a build on Netlify only if I manually press the "Clear cache and deploy" button.

If I just update the content on DATO the build on Netlify fails.

Here's the error on the build process:

Error: The plugin "gatsby-source-datocms" deleted a node of a type owned by an other plugin. The node type "DatoCmsField" is owned by "undefined". The node object passed to "deleteNode": { "id": "DatoCmsField-1026963", "parent": null, "children": [], "internal": { "type": "DatoCmsField", "contentDigest": "64bc17cb46a0c0e43c824c3e94327726", "counter": 65, "owner": "gatsby-source-datocms" }, "label": "Título", "fieldType": "string", "apiKey": "titulo", "localized": false, "validators": { "required": {} }, "position": 1, "appeareance": { "addons": [], "editor": "single_line", "parameters": { "heading": false } }, "defaultValue": null, "originalId": "1026963" } The plugin deleting the node: { "resolve": "/opt/build/repo/node_modules/gatsby-source-datocms", "id": "13634124-684a-5f85-ab6e-0cf0a941c125", "name": "gatsby-source-datocms", "version": "2.2.4", "pluginOptions": { "plugins": [], "apiToken": "eba6671d72345c02e8573ae208eed0", "previewMode": false, "disableLiveReload": false }, "nodeAPIs": [ "createSchemaCustomization", "sourceNodes" ], "browserAPIs": [], "ssrAPIs": [], "pluginFilepath": "/opt/build/repo/node_modules/gatsby-source-datocms" }

wildpow commented 4 years ago

I get the same error after updating dependencies.

Versions before the update.

deps2

Options I found that fixes this:

  1. Update everything besides gatsby.
  2. Update everything besides gatsby-source-datocms and react-helmet.
stippets commented 4 years ago

@matjack1 thank you for the PR that addresses this issue! Do you have a timeframe for when this PR will be merged and a new release made?

BlainInc commented 4 years ago

Okay here's my variation on the issue:

I'm trying to execute yarn build. I want to push to Github Pages. I am not using Netlify so those suggestions are neither here nor there with respect to my problem. I am still new to the platform so this is a pretty confusing error to get after following all of the instructions outlined here: https://www.gatsbyjs.org/docs/quick-start/ and here: https://github.com/datocms/gatsby-portfolio

As far as I can tell, Yarn reports that my dependencies are good. Says everything is up to date when I try to run Yarn install again in the repo path. Yarn upgrade having been done, it still gives me the same error. I am not using NPM to manage the packages on this run of the repo, and having used NPM before, it still threw the same error. I don't think it has much to do with that.

I don't have any such folder anywhere in my repo directories called ".cache" to delete so I'm not sure that I can follow those instructions. Let me know what I'm looking for.

To build this repo in the first place, I started by cloning this repo: https://github.com/datocms/gatsby-portfolio and then $ yarn add gatsby-cli $ yarn install $ echo 'DATO_API_TOKEN=fbc18b6a712b88fbb7d5b2dd3c610f' >> .env $ yarn develop -- WORKED at this point, so I CTRL-C terminated the process and tried to $ yarn build

Then this is the error I got:

ERROR #11321 PLUGIN

"gatsby-source-datocms" threw an error while running the sourceNodes lifecycle:

The plugin "gatsby-source-datocms" deleted a node of a type owned by another plugin.

      The node type "DatoCmsField" is owned by "undefined".

      The node object passed to "deleteNode":

      {
"id": "DatoCmsField-1044934",
"parent": null,
"children": [],
"internal": {
    "type": "DatoCmsField",
    "contentDigest": "258217ba587ce6a3eff553e11f679df0",
    "counter": 37,
    "owner": "gatsby-source-datocms"
},
"label": "SEO Settings",
"fieldType": "seo",
"apiKey": "seo_settings",
"localized": false,
"validators": {},
"position": 2,
"appeareance": {
    "addons": [],
    "editor": "seo",
    "parameters": {}
},
"defaultValue": null,
"originalId": "1044934"

}

      The plugin deleting the node:

      {
"resolve": "/Users/blain/blaininc.github.io/node_modules/gatsby-source-datocms",
"id": "e15658cd-c6f7-5c68-80d4-bb3d82c23a2b",
"name": "gatsby-source-datocms",
"version": "2.2.4",
"pluginOptions": {
    "plugins": [],
    "apiToken": "fbc18b6a712b88fbb7d5b2dd3c610f"
},
"nodeAPIs": [
    "createSchemaCustomization",
    "sourceNodes"
],
"browserAPIs": [],
"ssrAPIs": [],
"pluginFilepath": "/Users/blain/blaininc.github.io/node_modules/gatsby-source-datocms"

}

Error: The plugin "gatsby-source-datocms" deleted a node of a type owned by an other plugin. The node type "DatoCmsField" is owned by "undefined". The node object passed to "deleteNode": { "id": "DatoCmsField-1044934", "parent": null, "children": [], "internal": { "type": "DatoCmsField", "contentDigest": "258217ba587ce6a3eff553e11f679df0", "counter": 37, "owner": "gatsby-source-datocms" }, "label": "SEO Settings", "fieldType": "seo", "apiKey": "seo_settings", "localized": false, "validators": {}, "position": 2, "appeareance": { "addons": [], "editor": "seo", "parameters": {} }, "defaultValue": null, "originalId": "1044934" } The plugin deleting the node: { "resolve": "/Users/blain/blaininc.github.io/node_modules/gatsby-source-dat ocms", "id": "e15658cd-c6f7-5c68-80d4-bb3d82c23a2b", "name": "gatsby-source-datocms", "version": "2.2.4", "pluginOptions": { "plugins": [], "apiToken": "fbc18b6a712b88fbb7d5b2dd3c610f" }, "nodeAPIs": [ "createSchemaCustomization", "sourceNodes" ], "browserAPIs": [], "ssrAPIs": [], "pluginFilepath": "/Users/blain/blaininc.github.io/node_modules/gatsby-sou rce-datocms" }

not finished source and transform nodes - 2.119s not finished loading DatoCMS content - 2.103s error Command failed with exit code 1.

Please advise. Big thank.

BlainInc commented 4 years ago

Okay so God knows why but if I run $ yarn add gatsby-transformer-remark

I can then run yarn develop successfully, only once, and it will post a minor error:

/Users/blain/blaininc.github.io/src/components/layout.js 93:19 warning A control must be associated with a text label jsx-a11y/control-has-associated-label

✖ 1 problem (0 errors, 1 warning)

BUT the localhost 8000 will stand up successfully

I cannot run yarn develop a second time, without again running $ yarn add gatsby-transformer-remark

Once I run yarn add gatsby-transformer-remark again I can then run $ yarn build

which then runs a successful build operation with no errors posted.

Bizarre. Why would this work? Why would it stop working unless I reinstall that component again? What is happening there?

stippets commented 4 years ago

@BlainInc could you post your package.json file or the output of running yarn outdated so we can see better what you have installed? Also what version of node are you running?

stefanoverna commented 4 years ago

Alright, v2.2.5 of the plugin should hopefully fix the issue, let us know if it works for you guys, and thanks for the help so far!

PHironaka commented 4 years ago

This worked for me, thank you @stefanoverna !

Masadow commented 4 years ago

@stefanoverna neat, I'll try that later.

@BlainInc Beware, you posted your datocms api key token !!!

juamecos commented 4 years ago

Hi, I used gatsby clean command and after gatsby build and worked perfectly.