Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in createPage cycle show between lines of GraphQL query #18413

Closed
GKJCJG opened this issue Oct 9, 2019 · 5 comments
Closed

Errors in createPage cycle show between lines of GraphQL query #18413

GKJCJG opened this issue Oct 9, 2019 · 5 comments
Assignees
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change

Comments

@GKJCJG
Copy link

GKJCJG commented Oct 9, 2019

Description

When an error occurs in the createPage cycle, the error message often points to part of the GraphQL query even when the error occurred in code.

Steps to reproduce

Throw an error in a plugin that manipulates MarkdownAST.

Expected result

The error message should point to the lines of code in which the error actually occurred. Adding some error logging to createPages showed that the error was occurring in my Prism plugin:

{ TypeError: Cannot read property 'rest' of undefined
      at Object.tokenize (.../prismjs/prism.js:423:22)
      at Object.highlight (.../prismjs/prism.js:286:18)
      at module.exports (.../gatsby-remark-prismjs/highlight-code.js:47:29)
      at node (.../gatsby-remark-prismjs/index.js:73:193)
      at overload (.../gatsby-remark-prismjs/node_modules/unist-util-visit/index.js:27:12)
      at one (.../unist-util-visit-parents/index.js:34:25)
      at all (.../unist-util-visit-parents/index.js:57:16)
      at one (.../unist-util-visit-parents/index.js:42:28)
      at visitParents (.../unist-util-visit-parents/index.js:26:3)
      at visit (.../gatsby-remark-prismjs/node_modules/unist-util-visit/index.js:22:3)
      at module.exports (.../gatsby-remark-prismjs/index.js:30:3)
      at Promise.each.plugin (.../gatsby-transformer-remark/extend-node-type.js:298:20)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)
  From previous event:
      at .../gatsby-transformer-remark/extend-node-type.js:294:23
      at Generator.next (<anonymous>)
      at asyncGeneratorStep (.../@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (.../@babel/runtime/helpers/asyncToGenerator.js:25:9)
    message: 'Cannot read property \'rest\' of undefined',
    locations: [ [Object] ],
    path: [ 'allMarkdownRemark', 'edges', 115, 'node', 'excerpt' ] }

Actual result

The error message points to the GraphQL query that was running to produce the page requested.

e.g.

error #11321 PLUGIN 
"gatsby-node.js" threw an error while running the createPages lifecycle:
Cannot read property 'rest' of undefined
GraphQL request (9:21)
 8:                     }
 9:                     excerpt
                        ^
10:                     frontmatter {
,Cannot read property 'rest' of undefined

GraphQL request (9:21)
 8:                     }
 9:                     excerpt
                        ^
10:                     frontmatter {

See our docs page for more info on this error: https://gatsby.dev/issue-how-to

Environment

Has occurred on a Red Had Linux machine and a Windows 10 machine.

npmPackages:
gatsby: 2.13.32 => 2.13.32
gatsby-cli: 2.5.12 => 2.5.12
gatsby-plugin-catch-links: 2.0.13 => 2.0.13
gatsby-plugin-less: 2.0.12 => 2.0.12
gatsby-plugin-matomo: 0.7.0 => 0.7.0
gatsby-plugin-mdx: 1.0.33 => 1.0.33
gatsby-plugin-nprogress: 2.0.10 => 2.0.10
gatsby-plugin-react-helmet: 3.0.12 => 3.0.12
gatsby-plugin-typescript: 2.0.13 => 2.0.13
gatsby-plugin-webpack-bundle-analyzer: 1.0.4 => 1.0.4
gatsby-remark-autolink-headers: 2.0.16 => 2.0.16
gatsby-remark-code-titles: 1.1.0 => 1.1.0
gatsby-remark-copy-linked-files: 2.0.12 => 2.0.12
gatsby-remark-embed-snippet: 3.2.4 => 3.2.4
gatsby-remark-embed-video: 1.7.1 => 1.7.1
gatsby-remark-emojis: ^0.3.2 => 0.3.2
gatsby-remark-prismjs: 3.3.17 => 3.3.3
gatsby-source-elasticsearch: 0.1.0 => 0.1.0
gatsby-source-filesystem: 2.0.33 => 2.0.33
gatsby-transformer-json: 2.2.4 => 2.2.4
gatsby-transformer-remark: 2.3.12 => 2.3.12

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 30, 2019
@gatsbot
Copy link

gatsbot bot commented Oct 30, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@GKJCJG
Copy link
Author

GKJCJG commented Nov 1, 2019

Away, gatsbot, away! I'll see about opening a PR soon.

@gatsbot
Copy link

gatsbot bot commented Nov 12, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Nov 12, 2019
@LekoArts LekoArts added type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Dec 6, 2019
@LekoArts LekoArts self-assigned this Dec 6, 2019
@LekoArts LekoArts reopened this Dec 6, 2019
@LekoArts LekoArts added the status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. label Jan 21, 2020
@LekoArts
Copy link
Contributor

@GKJCJG Could you please post a reproduction of this? I'm not able to see the behavior you're describing. In my test runs the error shows the complete stacktrace.

@GKJCJG
Copy link
Author

GKJCJG commented Jan 28, 2020

@LekoArts in the last couple of weeks, I've noticed that the behavior of these error messages has changed to show the full stack trace rather than the just the query. I didn't watch closely to see whether a particular version change anywhere in my packages produced the change, but it does seem that the behavior has improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change
Projects
None yet
Development

No branches or pull requests

3 participants