Skip to content

Commit

Permalink
fix(gatsby-source-drupal): Ensure node updates are handled sequential…
Browse files Browse the repository at this point in the history
…ly to avoid race conditions when saving nodes (#36026)

* Properly await creating relationships to prevent racde condition where sometimes old versions of nodes overwrite new versions

* make mocked cache async & fix another async problem
  • Loading branch information
KyleAMathews committed Jul 13, 2022
1 parent 9c0359d commit 428355c
Show file tree
Hide file tree
Showing 5 changed files with 879 additions and 115 deletions.
395 changes: 395 additions & 0 deletions packages/gatsby-source-drupal/src/__tests__/fixtures/paragraph-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,395 @@
[
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": {
"type": "node--page",
"id": "6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb",
"links": {
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb?resourceVersion=id%3A13"
}
},
"attributes": {
"drupal_internal__nid": 2,
"drupal_internal__vid": 13,
"langcode": "en",
"revision_timestamp": "2022-06-30T13:14:32+00:00",
"revision_log": null,
"status": true,
"title": "Testing paragraph fields",
"created": "2022-06-30T13:13:49+00:00",
"changed": "2022-06-30T13:14:32+00:00",
"promote": false,
"sticky": false,
"default_langcode": true,
"revision_translation_affected": true,
"path": {
"alias": null,
"pid": null,
"langcode": "en"
},
"body": {
"value": "<p>Hi</p>\r\n",
"format": "basic_html",
"processed": "<p>Hi</p>",
"summary": ""
}
},
"relationships": {
"node_type": {
"data": {
"type": "node_type--node_type",
"id": "18674fce-64c0-4659-9ef3-daa1515ebbed",
"meta": {
"drupal_internal__target_id": "page"
}
},
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/node_type?resourceVersion=id%3A13"
},
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/relationships/node_type?resourceVersion=id%3A13"
}
}
},
"revision_uid": {
"data": {
"type": "user--user",
"id": "9e347e85-8840-44a7-994e-89a5a3e7c2b5",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/revision_uid?resourceVersion=id%3A13"
},
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/relationships/revision_uid?resourceVersion=id%3A13"
}
}
},
"uid": {
"data": {
"type": "user--user",
"id": "9e347e85-8840-44a7-994e-89a5a3e7c2b5",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/uid?resourceVersion=id%3A13"
},
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/relationships/uid?resourceVersion=id%3A13"
}
}
},
"field_content": {
"data": [
{
"type": "paragraph--image",
"id": "e7861064-0009-4458-bf6e-0284d34bb00d",
"meta": {
"target_revision_id": 37,
"drupal_internal__target_id": 6
}
},
{
"type": "paragraph--something",
"id": "b28b4fcd-cea7-4e27-b2c7-ed09a3dad976",
"meta": {
"target_revision_id": 38,
"drupal_internal__target_id": 7
}
}
],
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/field_content?resourceVersion=id%3A13"
},
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/relationships/field_content?resourceVersion=id%3A13"
}
}
},
"field_tag": {
"data": [],
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/field_tag?resourceVersion=id%3A13"
},
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb/relationships/field_tag?resourceVersion=id%3A13"
}
}
}
}
},
"links": {
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/node/page/6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb?resourceVersion=id%3A13"
}
},
"id": "6a5db0d4-4a0f-4a4b-9048-7d26e29fdacb",
"action": "insert",
"langcode": "en",
"attributes": {
"langcode": "en",
"drupal_internal__revision_id": "13"
}
},
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": {
"type": "paragraph--something",
"id": "b28b4fcd-cea7-4e27-b2c7-ed09a3dad976",
"links": {
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/something/b28b4fcd-cea7-4e27-b2c7-ed09a3dad976?resourceVersion=id%3A38"
}
},
"attributes": {
"drupal_internal__id": 7,
"drupal_internal__revision_id": 38,
"langcode": "en",
"status": true,
"created": "2022-06-30T13:14:20+00:00",
"parent_id": "2",
"parent_type": "node",
"parent_field_name": "field_content",
"behavior_settings": [],
"default_langcode": true,
"revision_translation_affected": true,
"field_text_me": [
{
"value": "<p>Text</p>\r\n",
"format": "basic_html",
"processed": "<p>Text</p>",
"summary": ""
}
]
},
"relationships": {
"paragraph_type": {
"data": {
"type": "paragraphs_type--paragraphs_type",
"id": "b6341f8e-72af-4e13-bd7b-bc54b9ff9b3b",
"meta": {
"drupal_internal__target_id": "something"
}
},
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/something/b28b4fcd-cea7-4e27-b2c7-ed09a3dad976/paragraph_type?resourceVersion=id%3A38"
},
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/something/b28b4fcd-cea7-4e27-b2c7-ed09a3dad976/relationships/paragraph_type?resourceVersion=id%3A38"
}
}
}
}
},
"links": {
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/something/b28b4fcd-cea7-4e27-b2c7-ed09a3dad976?resourceVersion=id%3A38"
}
},
"id": "b28b4fcd-cea7-4e27-b2c7-ed09a3dad976",
"action": "update",
"langcode": "en",
"attributes": {
"langcode": "en",
"drupal_internal__revision_id": "38"
}
},
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": {
"type": "file--file",
"id": "68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd",
"links": {
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/file/file/68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd"
}
},
"attributes": {
"drupal_internal__fid": 6,
"langcode": "en",
"filename": "DSCF2841_1.jpg",
"uri": {
"value": "public://2022-06/DSCF2841_1.jpg",
"url": "/sites/default/files/2022-06/DSCF2841_1.jpg"
},
"filemime": "image/jpeg",
"filesize": 979596,
"status": true,
"created": "2022-06-30T13:14:17+00:00",
"changed": "2022-06-30T13:14:32+00:00"
},
"relationships": {
"uid": {
"data": {
"type": "user--user",
"id": "9e347e85-8840-44a7-994e-89a5a3e7c2b5",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/file/file/68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd/uid"
},
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/file/file/68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd/relationships/uid"
}
}
}
}
},
"links": {
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/file/file/68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd"
}
},
"id": "68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd",
"action": "update",
"langcode": "en",
"attributes": {
"langcode": "en",
"drupal_internal__revision_id": null
}
},
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": {
"type": "paragraph--image",
"id": "e7861064-0009-4458-bf6e-0284d34bb00d",
"links": {
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/image/e7861064-0009-4458-bf6e-0284d34bb00d?resourceVersion=id%3A37"
}
},
"attributes": {
"drupal_internal__id": 6,
"drupal_internal__revision_id": 37,
"langcode": "en",
"status": true,
"created": "2022-06-30T13:14:07+00:00",
"parent_id": "2",
"parent_type": "node",
"parent_field_name": "field_content",
"behavior_settings": [],
"default_langcode": true,
"revision_translation_affected": true
},
"relationships": {
"paragraph_type": {
"data": {
"type": "paragraphs_type--paragraphs_type",
"id": "27255954-ae1c-43ce-b27b-ff594b718b26",
"meta": {
"drupal_internal__target_id": "image"
}
},
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/image/e7861064-0009-4458-bf6e-0284d34bb00d/paragraph_type?resourceVersion=id%3A37"
},
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/image/e7861064-0009-4458-bf6e-0284d34bb00d/relationships/paragraph_type?resourceVersion=id%3A37"
}
}
},
"field_image": {
"data": {
"type": "file--file",
"id": "68e88bbe-4c59-4abd-bca2-7cda4ca1f2cd",
"meta": {
"alt": "alt text",
"title": "",
"width": 1500,
"height": 1000,
"drupal_internal__target_id": 6
}
},
"links": {
"related": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/image/e7861064-0009-4458-bf6e-0284d34bb00d/field_image?resourceVersion=id%3A37"
},
"self": {
"href": "https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/image/e7861064-0009-4458-bf6e-0284d34bb00d/relationships/field_image?resourceVersion=id%3A37"
}
}
}
}
},
"links": {
"self": {
"href":
"https://dev-drupal-bug-reproduction.pantheonsite.io/jsonapi/paragraph/image/e7861064-0009-4458-bf6e-0284d34bb00d?resourceVersion=id%3A37"
}
},
"id": "e7861064-0009-4458-bf6e-0284d34bb00d",
"action": "update",
"langcode": "en",
"attributes": {
"langcode": "en",
"drupal_internal__revision_id": "37"
}
}
]
Loading

0 comments on commit 428355c

Please sign in to comment.