`gatsby build` fails because `node.internal.content` is undefined
Problem
gatsby build fails because node.internal.content is undefined in getOrgAST in orga-util.js:line 49 compiled in node_modules/ when evaluating GraphQL's term html.
In TypeScript, here https://github.com/orgapp/orgajs/blob/2fc346ed2481faff2355a894acda72aa1fc0352e/packages/gatsby-transformer-orga/src/orga-util.ts#L48
The error Cannot read property 'indexOf' of undefined occurs in read in text-kit because the 'string' passed from node.internal.content is in fact undefined.
I'm making a project using gatsby-transformer-orga referring to https://github.com/orgapp/gatsby-orga .
Then I encountered this error when I added many org files to src/pages/.
How can I do fix this error?
Reproduction
- This error does not occur when there are a few org-files in
src/pages/. - This error occurs by adding many org-files to
src/pages/. (Although I don't know contents are matter or not, the error did not occur by adding just many files that are same content.) - But I could not reproduce the org-file which causes this error. After
npm run clean, the file varies. (I don't know why.) - When the error occurs, orga-util.js:line 49 is called only one time. (At the time,
node.internal.contentis undefined)
I prepared a sample project. Please do npm install, then npm run build causes this error.
Error message
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Cannot read property 'indexOf' of undefined
1 | query BlogPostBySlug($id: String!) {
2 | orgContent(id: {eq: $id}) {
> 3 | html
| ^
4 | metadata {
5 | title
6 | date
7 | tags
8 | export_file_name
9 | }
10 | parent {
11 | ... on OrgFile {
12 | parent {
13 | ... on File {
File path: /Users/path/to/my-gatsby-orga-sample/src/templates/post.js
Url path: /photoshop
Plugin: none
TypeError: Cannot read property 'indexOf' of undefined
- read.ts:17 Object.exports.default [as read]
[my-gatsby-orga-sample]/[text-kit]/src/read.ts:17:21
- reader.ts:13 Object.read
[my-gatsby-orga-sample]/[orga]/src/reader.ts:13:7
- index.ts:34 Object.tokenize
[my-gatsby-orga-sample]/[orga]/src/tokenize/index.ts:34:18
- index.ts:13 Object.parse
[my-gatsby-orga-sample]/[orga]/src/index.ts:13:17
- orga-util.js:49
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:49:32
- new Promise
- orga-util.js:48
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:48:16
- Generator.next
- orga-util.js:7
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:7:71
- new Promise
- orga-util.js:3 __awaiter
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:3:12
- orga-util.js:47 getOrgAST
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:47:12
- orga-util.js:34 Object.<anonymous>
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:34:34
- Generator.next
- orga-util.js:4 fulfilled
[my-gatsby-orga-sample]/[gatsby-transformer-orga]/orga-util.js:4:58
not finished run page queries - 0.767s