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

api-runner-node.js: TypeError: Cannot read property 'referencePaths' of undefined #20488

Closed
muescha opened this issue Jan 8, 2020 · 2 comments · Fixed by #20517
Closed

api-runner-node.js: TypeError: Cannot read property 'referencePaths' of undefined #20488

muescha opened this issue Jan 8, 2020 · 2 comments · Fixed by #20517

Comments

@muescha
Copy link
Contributor

muescha commented Jan 8, 2020

Description

Describe the issue that you're seeing.

Steps to reproduce

  • checkout gatsby
  • cd www
  • install packages
  • run gatsby develop

Expected result

no error

Actual result

error:

parsing error {
  file: 'gatsby/src/utils/api-runner-node.js',
  e: TypeError: Cannot read property 'referencePaths' of undefined
      at CallExpression (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/find-api-calls.js:123:52)
      at NodePath._call (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/path/context.js:55:20)
      at NodePath.call (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/path/context.js:42:17)
      at NodePath.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/path/context.js:90:31)
      at TraversalContext.visitQueue (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitSingle (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:84:19)
      at TraversalContext.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:140:19)
      at Function.traverse.node (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/index.js:84:17)
      at NodePath.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/path/context.js:97:18)
      at TraversalContext.visitQueue (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitMultiple (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:79:17)
      at TraversalContext.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:138:19)
      at Function.traverse.node (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/index.js:84:17)
      at NodePath.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/path/context.js:97:18)
      at TraversalContext.visitQueue (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitMultiple (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:79:17)
      at TraversalContext.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:138:19)
      at Function.traverse.node (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/index.js:84:17)
      at NodePath.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/path/context.js:97:18)
      at TraversalContext.visitQueue (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitSingle (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:84:19)
      at TraversalContext.visit (/Users/muescha/Work/gatsby/github/gatsby/www/plugins/gatsby-transformer-gatsby-api-calls/node_modules/@babel/traverse/lib/context.js:140:19)
}

Environment

Run gatsby info --clipboard in your project directory and paste the output here:

  System:
    OS: macOS Mojave 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.13.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 79.0.3945.88
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.18.8 => 2.18.18 
    gatsby-design-tokens: ~1.0.10 => 1.0.10 
    gatsby-image: ^2.2.34 => 2.2.37 
    gatsby-plugin-canonical-urls: ^2.1.16 => 2.1.18 
    gatsby-plugin-catch-links: ^2.1.19 => 2.1.21 
    gatsby-plugin-emotion: ^4.1.16 => 4.1.18 
    gatsby-plugin-feed: ^2.3.23 => 2.3.25 
    gatsby-plugin-google-analytics: ^2.1.29 => 2.1.31 
    gatsby-plugin-google-tagmanager: ^2.1.18 => 2.1.20 
    gatsby-plugin-guess-js: ^1.1.26 => 1.1.28 
    gatsby-plugin-layout: ^1.1.16 => 1.1.18 
    gatsby-plugin-mailchimp: ^2.2.3 => 2.2.3 
    gatsby-plugin-manifest: ^2.2.31 => 2.2.34 
    gatsby-plugin-mdx: ^1.0.59 => 1.0.64 
    gatsby-plugin-netlify: ^2.1.28 => 2.1.30 
    gatsby-plugin-netlify-cache: ^0.1.0 => 0.1.0 
    gatsby-plugin-nprogress: ^2.1.15 => 2.1.17 
    gatsby-plugin-offline: ^3.0.27 => 3.0.30 
    gatsby-plugin-react-helmet: ^3.1.16 => 3.1.18 
    gatsby-plugin-sharp: ^2.3.5 => 2.3.10 
    gatsby-plugin-sitemap: ^2.2.22 => 2.2.24 
    gatsby-plugin-theme-ui: ^0.2.43 => 0.2.43 
    gatsby-plugin-twitter: ^2.1.15 => 2.1.17 
    gatsby-plugin-typography: ^2.3.18 => 2.3.20 
    gatsby-remark-autolink-headers: ^2.1.19 => 2.1.22 
    gatsby-remark-code-titles: ^1.1.0 => 1.1.0 
    gatsby-remark-copy-linked-files: ^2.1.31 => 2.1.33 
    gatsby-remark-embedder: ^1.6.0 => 1.7.0 
    gatsby-remark-graphviz: ^1.1.18 => 1.1.20 
    gatsby-remark-images: ^3.1.35 => 3.1.39 
    gatsby-remark-normalize-paths: ^1.0.0 => 1.0.0 
    gatsby-remark-prismjs: ^3.3.25 => 3.3.29 
    gatsby-remark-responsive-iframe: ^2.2.28 => 2.2.30 
    gatsby-remark-smartypants: ^2.1.17 => 2.1.19 
    gatsby-source-airtable: ^2.0.12 => 2.0.12 
    gatsby-source-filesystem: ^2.1.40 => 2.1.43 
    gatsby-source-npm-package-search: ^2.1.19 => 2.1.21 
    gatsby-transformer-csv: ^2.1.19 => 2.1.21 
    gatsby-transformer-documentationjs: ^4.1.20 => 4.1.22 
    gatsby-transformer-remark: ^2.6.39 => 2.6.45 
    gatsby-transformer-screenshot: ^2.1.44 => 2.1.46 
    gatsby-transformer-sharp: ^2.3.7 => 2.3.9 
    gatsby-transformer-yaml: ^2.2.18 => 2.2.20 
  npmGlobalPackages:
    gatsby-cli: 2.8.13
@muescha
Copy link
Contributor Author

muescha commented Jan 8, 2020

apiRunnerName is null here one time:

const apiRunnerName = test.node.id.name
const references =
test.scope.bindings[apiRunnerName].referencePaths

@muescha
Copy link
Contributor Author

muescha commented Jan 9, 2020

an investigation with a manual git bisect with the history i found this:

  • with the PR feat(gatsby): Improve structured errors around GraphQL #20120 (feat(gatsby): Improve structured errors around GraphQL) the error comes in with a new file api-runner-node-error-parser.js
  • the apiRunnerName seems to become undefined for the new file packages/gatsby/src/utils/api-runner-node-error-parser.js

possible fix:

  • since the new file is an helper function and not need a link to the source (see PR feat(www): Add source links to API docs #14240 feat(www): Add source links to API docs) i assume it can be fixed with a "monkey patch": renaming the file to something different and not including api-runner-node fixes the error, because of then it not matches the test for the bucket:

const buckets = [
{
test: /api-runner-node/,
group: `NodeAPI`,
},

in
if (
arg.quasis &&
(bucket = buckets.find(a => a.test.test(arg.quasis[0].value.raw)))
) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant