cometkim / gatsby-plugin-typegen

Let's give developers using GatsbyJS better DX with extreme type-safety
https://www.gatsbyjs.org/packages/gatsby-plugin-typegen/
MIT License
204 stars 23 forks source link

gatsby 2.23.22: TypeError: unsubscribeQueryExtraction is not a function #93

Closed tony closed 4 years ago

tony commented 4 years ago

Hi @cometkim! Thank you for the project!

I believe this issue came up here: https://github.com/gatsbyjs/gatsby/issues/25378 / https://github.com/gatsbyjs/gatsby/commit/e5ce35b

image

❯ gatsby develop --port 8009
success open and validate gatsby-configs - 0.083s
success load plugins - 0.571s
success onPreInit - 0.005s
success initialize cache - 0.006s
success copy gatsby files - 0.014s
success onPreBootstrap - 0.006s
success createSchemaCustomization - 0.006s
success source and transform nodes - 1.430s
warn There are conflicting field types in your data.

If you have explicitly defined a type for those fields, you can safely ignore this warning message.
Otherwise, Gatsby will omit those fields from the GraphQL schema.

If you know all field types in advance, the best strategy is to explicitly define them with the `createTypes` action, and skip inference with the `@dontInfer` directive.
See https://www.gatsbyjs.org/docs/actions/#createTypes
Reference.year:
 - type: date
   value: '2010'
 - type: number
   value: 1977
Reference.volume:
 - type: number
   value: 130
 - type: string
   value: '52 3'
success building schema - 0.654s
success createPages - 2.062s
success createPagesStatefully - 0.095s
success updating schema - 0.121s
success write out redirect data - 0.004s
success Build manifest and related icons - 0.103s

 ERROR #11321  PLUGIN

"gatsby-plugin-typegen" threw an error while running the onPostBootstrap lifecycle:

unsubscribeQueryExtraction is not a function

   96 |   } = pluginOptions;
   97 |   reporter.verbose('[typegen] End-up listening on query extraction.');
>  98 |   unsubscribeQueryExtraction();
      |   ^
   99 |   const state = store.getState();
  100 |   const basePath = state.program.directory;
  101 |   const pluginState = {

File: node_modules/gatsby-plugin-typegen/gatsby-node.js:98:3

  TypeError: unsubscribeQueryExtraction is not a function

  - gatsby-node.js:98 Object.onPostBootstrap
    [ourwebsite]/[gatsby-plugin-typegen]/gatsby-node.js:98:3

  - api-runner-node.js:259 runAPI
    [ourwebsite]/[gatsby]/dist/utils/api-runner-node.js:259:37

  - From previous event:

  - api-runner-node.js:261 runAPI
    [ourwebsite]/[gatsby]/dist/utils/api-runner-node.js:261:22

  - api-runner-node.js:378 Promise.catch.decorateEvent.pluginName
    [ourwebsite]/[gatsby]/dist/utils/api-runner-node.js:378:15

  - From previous event:

  - api-runner-node.js:377
    [ourwebsite]/[gatsby]/dist/utils/api-runner-node.js:377:12

  - timers.js:456 processImmediate
    internal/timers.js:456:21

  - From previous event:

  - api-runner-node.js:371
    [ourwebsite]/[gatsby]/dist/utils/api-runner-node.js:371:11

  - From previous event:

  - api-runner-node.js:278 module.exports
    [ourwebsite]/[gatsby]/dist/utils/api-runner-node.js:278:12

  - post-bootstrap.js:24 postBootstrap
    [ourwebsite]/[gatsby]/dist/services/post-bootstrap.js:24:36

  - develop-process.js:176 src
    [ourwebsite]/[gatsby]/dist/commands/develop-process.js:176:47

success onPostBootstrap - 0.145s
info bootstrap finished - 6.425s
success onPreExtractQueries - 0.002s
success extract queries from components - 0.367s
success write out requires - 0.199s
success run static queries - 0.134s - 3/3 22.32/s
success run page queries - 0.475s - 138/138 290.26/s
success write out requires - 0.002s
success Generating image thumbnails - 7.038s - 432/432 61.38/s
⠀
You can now view yoursite.org in the browser.
⠀
  http://localhost:8009/

yarn.lock diff

version diff of gatsby packages that makes it begin: ```diff diff --git a/yarn.lock b/yarn.lock index 7160a838..8f072d9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9170,7 +9170,7 @@ functional-red-black-tree@^1.0.1: resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= -gatsby-cli@^2.12.58, gatsby-cli@^2.12.59: +gatsby-cli@^2.12.59: version "2.12.59" resolved "https://registry.yarnpkg.com/gatsby-cli/-/gatsby-cli-2.12.59.tgz#faa9a16c9dd6678473e0683256c39a97faa76322" integrity sha512-iQPFgBbZG1dLGtdNqB/gsnlwWu44rli/4J2VzYU3zwPguC9Zo3KMQxnrbIRY6CB1ryWQl+m/FZxO4umkEk8IUg== @@ -9364,7 +9364,7 @@ gatsby-plugin-offline@^3.2.16: lodash "^4.17.15" workbox-build "^4.3.1" -gatsby-plugin-page-creator@^2.3.15, gatsby-plugin-page-creator@^2.3.16: +gatsby-plugin-page-creator@^2.3.16: version "2.3.16" resolved "https://registry.yarnpkg.com/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-2.3.16.tgz#7280a1b7495697d38e213c1bfe6ce3fd2f80569a" integrity sha512-3HK0K+9yotRypNSeM/d2PlhW3YnFrQQ7MKF79sGSEM5x++9RiXYB1YbjibNw5rsM0SI/YCQqAAJi86kNU0B3SQ== @@ -9632,154 +9632,7 @@ gatsby-transformer-yaml@^2.4.9: lodash "^4.17.15" unist-util-select "^1.5.0" -gatsby@2.23.21: - version "2.23.21" - resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-2.23.21.tgz#44099dab466b12380c5ae4d6a92ce247119228ca" - integrity sha512-oR4E+v3ilih+hQ1KyDI9N9c5OUqpNyiw93vO2YCGnpIY+q2/ldUnjWQc9FLGgMxupNs9nnTtYT/UrpePHFQvzQ== - dependencies: - "@babel/code-frame" "^7.10.3" - "@babel/core" "^7.10.3" - "@babel/parser" "^7.10.3" - "@babel/polyfill" "^7.8.7" - "@babel/runtime" "^7.10.3" - "@babel/traverse" "^7.10.3" - "@hapi/joi" "^15.1.1" - "@mikaelkristiansson/domready" "^1.0.10" - "@pieh/friendly-errors-webpack-plugin" "1.7.0-chalk-2" - "@pmmmwh/react-refresh-webpack-plugin" "^0.3.3" - "@reach/router" "^1.3.4" - "@types/http-proxy" "^1.17.4" - "@typescript-eslint/eslint-plugin" "^2.24.0" - "@typescript-eslint/parser" "^2.24.0" - address "1.1.2" - autoprefixer "^9.8.4" - axios "^0.19.2" - babel-core "7.0.0-bridge.0" - babel-eslint "^10.1.0" - babel-loader "^8.1.0" - babel-plugin-add-module-exports "^0.3.3" - babel-plugin-dynamic-import-node "^2.3.3" - babel-plugin-remove-graphql-queries "^2.9.12" - babel-preset-gatsby "^0.5.1" - better-opn "1.0.0" - better-queue "^3.8.10" - bluebird "^3.7.2" - browserslist "^4.12.2" - cache-manager "^2.11.1" - cache-manager-fs-hash "^0.0.9" - chalk "^2.4.2" - chokidar "3.4.0" - common-tags "^1.8.0" - compression "^1.7.4" - convert-hrtime "^3.0.0" - copyfiles "^2.3.0" - core-js "^2.6.11" - cors "^2.8.5" - css-loader "^1.0.1" - date-fns "^2.14.0" - debug "^3.2.6" - del "^5.1.0" - detect-port "^1.3.0" - devcert "^1.1.0" - dotenv "^8.2.0" - eslint "^6.8.0" - eslint-config-react-app "^5.2.1" - eslint-loader "^2.2.1" - eslint-plugin-flowtype "^3.13.0" - eslint-plugin-graphql "^3.1.1" - eslint-plugin-import "^2.22.0" - eslint-plugin-jsx-a11y "^6.3.1" - eslint-plugin-react "^7.20.2" - eslint-plugin-react-hooks "^1.7.0" - event-source-polyfill "^1.0.15" - express "^4.17.1" - express-graphql "^0.9.0" - fast-levenshtein "^2.0.6" - file-loader "^1.1.11" - fs-exists-cached "1.0.0" - fs-extra "^8.1.0" - gatsby-cli "^2.12.58" - gatsby-core-utils "^1.3.11" - gatsby-graphiql-explorer "^0.4.10" - gatsby-link "^2.4.11" - gatsby-plugin-page-creator "^2.3.15" - gatsby-plugin-typescript "^2.4.13" - gatsby-react-router-scroll "^3.0.10" - gatsby-telemetry "^1.3.18" - glob "^7.1.6" - got "8.3.2" - graphql "^14.6.0" - graphql-compose "^6.3.8" - graphql-playground-middleware-express "^1.7.18" - hasha "^5.2.0" - http-proxy "^1.18.1" - invariant "^2.2.4" - is-relative "^1.0.0" - is-relative-url "^3.0.0" - is-wsl "^2.2.0" - jest-worker "^24.9.0" - json-loader "^0.5.7" - json-stringify-safe "^5.0.1" - latest-version "5.1.0" - lodash "^4.17.15" - md5-file "^3.2.3" - meant "^1.0.1" - micromatch "^3.1.10" - mime "^2.4.6" - mini-css-extract-plugin "^0.8.2" - mitt "^1.2.0" - mkdirp "^0.5.1" - moment "^2.27.0" - name-all-modules-plugin "^1.0.1" - normalize-path "^2.1.1" - null-loader "^3.0.0" - opentracing "^0.14.4" - optimize-css-assets-webpack-plugin "^5.0.3" - p-defer "^3.0.0" - parseurl "^1.3.3" - physical-cpu-count "^2.0.0" - pnp-webpack-plugin "^1.6.4" - postcss-flexbugs-fixes "^4.2.1" - postcss-loader "^3.0.0" - prompts "^2.3.2" - prop-types "^15.7.2" - query-string "^6.13.1" - raw-loader "^0.5.1" - react-dev-utils "^4.2.3" - react-error-overlay "^3.0.0" - react-hot-loader "^4.12.21" - react-refresh "^0.7.0" - redux "^4.0.5" - redux-thunk "^2.3.0" - semver "^5.7.1" - shallow-compare "^1.2.2" - signal-exit "^3.0.3" - slugify "^1.4.4" - socket.io "^2.3.0" - socket.io-client "2.3.0" - st "^2.0.0" - stack-trace "^0.0.10" - string-similarity "^1.2.2" - style-loader "^0.23.1" - terser-webpack-plugin "^1.4.4" - tmp "^0.2.1" - "true-case-path" "^2.2.1" - type-of "^2.0.1" - url-loader "^1.1.2" - util.promisify "^1.0.1" - uuid "^3.4.0" - v8-compile-cache "^1.1.2" - webpack "~4.43.0" - webpack-dev-middleware "^3.7.2" - webpack-dev-server "^3.11.0" - webpack-hot-middleware "^2.25.0" - webpack-merge "^4.2.2" - webpack-stats-plugin "^0.3.1" - webpack-virtual-modules "^0.2.2" - xstate "^4.11.0" - yaml-loader "^0.6.0" - -gatsby@>2.20.00: +gatsby@2.23.22, gatsby@>2.20.00: version "2.23.22" resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-2.23.22.tgz#40260b744c0d1537d5cad03c9d57f86fce67cf3f" integrity sha512-3kQUOeYZDle17tgvBD8DHIv2jjjKISV6c/+adRPxIBtcsA/zc+otrLXDD8PL77jd2xiE8X7/lMq2O4LsvOx+qQ== ```
cometkim commented 4 years ago

Thank you for reporting this @tony

Plugins depend on the lifecycle API, but Gatsby suddenly changed its behavior in the patch version. This breaks semantic versioning and I'm not sure what is the correct way to fix it.... :shrug:

cometkim commented 4 years ago

I think using onPreBootstrap instead of onPreExtractQueries should fix it.

cometkim commented 4 years ago

Fixed in v2.2.1

tony commented 4 years ago

@cometkim Thank you! This fixed it for me!