Gatsby: [V2] ENABLE_GATSBY_REFRESH_ENDPOINT breaks gatsby develop unless GATSBY_REFRESH_TOKEN is set to true

Created on 17 Jul 2018  Â·  6Comments  Â·  Source: gatsbyjs/gatsby

Description

When using v2 with Contentful, setting ENABLE_GATSBY_REFRESH_ENDPOINT=true in order to run a webhook for targeting __refresh results in the following error and doesn't compile successfully:

TypeError: Cannot destructure property `parentSpan` of 'undefined' or 'null'.

When I set GATSBY_REFRESH_TOKEN=true, the error disappears and the app compiles with no problem. However hot reloading still does not work and it is not refreshing source data like it did in v1.

Steps to reproduce

  • set up Gatsby site with Contentful
  • create webhook to target __refresh using ngrok
  • set environment variable ENABLE_GATSBY_REFRESH_ENDPOINT=true
  • update content in Contentful

Expected result

Source data should refresh and hot reloading should occur when changes are published in Contentful

Actual result

Gatsby develop stops and the following error shows:

TypeError: Cannot destructure property `parentSpan` of 'undefined' or 'null'.

Environment

  System:
    OS: macOS High Sierra 10.13.4
    CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.6.0 - /usr/local/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 67.0.3396.99
    Firefox: 61.0.1
    Safari: 11.1
  npmPackages:
    gatsby: 2.0.0-beta.29 => 2.0.0-beta.29
    gatsby-plugin-react-helmet: next => 3.0.0-beta.3
    gatsby-source-contentful: next => 2.0.1-beta.13
    gatsby-transformer-remark: next => 2.1.1-beta.3

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

bug

All 6 comments

Thanks for report @Treblesteph!

/cc @Moocar

That's the offender (missing param with tracing related stuff) - https://github.com/gatsbyjs/gatsby/blob/d863bcb1ef555926e4ba5af313cb153cedad1291/packages/gatsby/src/commands/develop.js#L124

https://github.com/gatsbyjs/gatsby/blob/d863bcb1ef555926e4ba5af313cb153cedad1291/packages/gatsby/src/utils/source-nodes.js#L29

Not sure if those should be recorded or discarded - this will be called when gatsby develop would be idle so not sure how tracing graphs would look like if we record those

This sounds like a bug added by https://github.com/gatsbyjs/gatsby/pull/6347

oh, and better response from @pieh :-)

Oops, yep. I forgot about sourceNodes being called during the develop command.

Tracing during the develop phase needs some more thought. A build span always "finishes", which means it can be viewed eventually. In the develop phase, the span never "finishes", so it can't be viewed in tracing backends.

There might be some way to view develop spans in the future, but for now, I recommend we just make the sourceNodes argument optional. This will cause the enclosed span to be recorded without a parentSpan. Which is completely legitimate.

@pieh I created a PR to make the args to sourceNodes optional. #6513

Thanks @Moocar !

@Treblesteph this should be fixed in [email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  Â·  3Comments

rossPatton picture rossPatton  Â·  3Comments

ferMartz picture ferMartz  Â·  3Comments

ghost picture ghost  Â·  3Comments

dustinhorton picture dustinhorton  Â·  3Comments