gatsby-orga icon indicating copy to clipboard operation
gatsby-orga copied to clipboard

Cannot read property 'split' of undefined

Open tareefdev opened this issue 5 years ago • 2 comments

I'm trying to move my blog from Hugo to Gatsby using orga. So I cloned the repo, installed the packages, built the site, and it works flawlessly. Then I started to move my files (~350) to the site as groups (20 ones each time), build and see if everything looks OK!

Sometimes I get the following error while building:

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Cannot read property 'split' of undefined

   1 | query BlogPostQuery($id: String!) {
   2 |   orgContent(id: {eq: $id}) {
>  3 |     html
     |     ^
   4 |     metadata {
   5 |       title
   6 |       date
   7 |     }
   8 |   }
   9 | }
  10 |

File path: /home/tareef/projects/gatsby-orga/src/templates/post.js
Url path: /about_read1
Plugin: none

It doesn't seem that it's about a specific file (about-read in this case), as the error happens unevenly. Sometimes gatsby clean solved it but many time doesn't.

What do you suggest to investigate the issue more deeply and found the reason behind it.

Thanks.

tareefdev avatar Jan 19 '20 17:01 tareefdev

Can confirm this.

When this happens, GraphiQL shows that the html is empty. This fits with the "no split of undefined' message.

I suspect a error in the parsing of the org source. I can make it go away by making some seemingly random changes in the org, like adding/removing blank lines.

Would it be useful to move this issue to https://github.com/orgapp/orgajs?

Update 1: The behavior suggests a timing issue, where an HTML generator is called asynchronously and the html value isn't set yet when we try to access it.

Update 2: This could be where the magic happens: https://github.com/orgapp/orgajs/blob/master/packages/gatsby-transformer-orga/src/extend-node-type.ts#L70

otech-nl avatar Feb 02 '20 07:02 otech-nl

I'd just like to echo what's been said here already: I'm migrating from Hakyll to Gatsby, and getting this error spuriously when running gatsby develop. Up until I saw the suggestion of running gatsby clean, I hadn't been able to run gatsby build once, but it worked after cleaning.

Has anyone found any other (or more reliable way) than running gatsby clean? And if we have a potential source of the issue (as linked by @otech-nl above), does anyone know what to do with this line to fix it?

thomasheartman avatar May 08 '20 18:05 thomasheartman