blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Blitz 0.42.0 causes build error #207

Closed JohannesKlauss closed 2 years ago

JohannesKlauss commented 2 years ago

What is the problem?

Pre 0.42.0 builds ran just fine, there are no code changes, we just upgraded to 0.42.0. Now the build is failing trying to generate static pages with react-query complaining that there is no QueryClient set:

Error: No QueryClient set, use QueryClientProvider to set one

Paste all your error logs here:

info  - Collecting page data  
[ ===] info  - Generating static pages (0/14)
Error occurred prerendering page "/login". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No QueryClient set, use QueryClientProvider to set one
    at useQueryClient (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/QueryClientProvider.js:36:11)
    at Object.useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/useMutation.js:27:61)
    at useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/data-client/react-query.js:228:35)
    at LoginForm (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/.next/server/chunks/5049.js:41:88)
    at tb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:55:138)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:254)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at X (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:64:97)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:58:27)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)

Error occurred prerendering page "/signup". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No QueryClient set, use QueryClientProvider to set one
    at useQueryClient (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/QueryClientProvider.js:36:11)
    at Object.useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/useMutation.js:27:61)
    at useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/data-client/react-query.js:228:35)
    at SignupForm (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/.next/server/pages/signup.js:59:56)
    at tb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:55:138)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:254)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at X (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:64:97)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:58:27)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)

Error occurred prerendering page "/reset-password". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No QueryClient set, use QueryClientProvider to set one
    at useQueryClient (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/QueryClientProvider.js:36:11)
    at Object.useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/useMutation.js:27:61)
    at useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/data-client/react-query.js:228:35)
    at ResetPasswordPage (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/.next/server/pages/reset-password.js:48:69)
    at tb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:55:138)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:254)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:375)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at X (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:64:97)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No QueryClient set, use QueryClientProvider to set one
    at useQueryClient (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/QueryClientProvider.js:36:11)
    at Object.useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/useMutation.js:27:61)
    at useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/data-client/react-query.js:228:35)
    at RequestEarlyAccess (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/.next/server/pages/index.js:196:57)
    at tb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:55:138)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:254)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at X (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:64:97)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:239)
    at X (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:64:97)
[  ==] info  - Generating static pages (8/14)
Error occurred prerendering page "/forgot-password". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No QueryClient set, use QueryClientProvider to set one
    at useQueryClient (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/QueryClientProvider.js:36:11)
    at Object.useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-query/lib/react/useMutation.js:27:61)
    at useMutation (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/data-client/react-query.js:228:35)
    at ForgotPasswordPage (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/.next/server/pages/forgot-password.js:42:69)
    at tb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:55:138)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:254)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at wb (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:57:375)
    at W (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:62:89)
    at X (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js:64:97)
info  - Generating static pages (14/14)

> Build error occurred
Error: Export encountered errors on following paths:
        /
        /forgot-password
        /login
        /reset-password
        /signup
    at /Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/export/index.js:480:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Span.traceAsyncFn (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/telemetry/trace/trace.js:60:20)
    at async /Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/build/index.js:759:17
    at async Span.traceAsyncFn (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/telemetry/trace/trace.js:60:20)
    at async /Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/build/index.js:637:13
    at async Span.traceAsyncFn (/Users/johannesklauss/Documents/Github/SyraAudio/Platforms/Wave/node_modules/next/dist/telemetry/trace/trace.js:60:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Process finished with exit code 1

Paste all relevant code snippets here:

const ResetPasswordPage = () => {
  const query = (0,next_stdlib__WEBPACK_IMPORTED_MODULE_1__.useRouterQuery)();
  const [resetPasswordMutation, {
    isSuccess
  }] = (0,next_data_client__WEBPACK_IMPORTED_MODULE_2__.useMutation)

// This is where the build complains for the reset password page
(app_auth_mutations_resetPassword__WEBPACK_IMPORTED_MODULE_8__.default); 

  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_9__.Container, {
    children: [/*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx(_mantine_core__WEBPACK_IMPORTED_MODULE_9__.Title, {
      order: 1,
      children: "Set a New Password"
    }), isSuccess ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)("div", {
      children: [/*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx("h2", {
        children: "Password Reset Successfully"
      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)("p", {
        children: ["Go to the ", /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx(next_link__WEBPACK_IMPORTED_MODULE_3__.Link, {
          href: next_stdlib__WEBPACK_IMPORTED_MODULE_1__.Routes.Home(),
          children: "homepage"
        })]
      })]
    }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsxs)(app_core_components_Form__WEBPACK_IMPORTED_MODULE_6__/* .Form */ .l, {
      submitText: "Reset Password",
      schema: app_auth_validations__WEBPACK_IMPORTED_MODULE_7__/* .ResetPassword */ .tq,
      initialValues: {
        password: '',
        passwordConfirmation: '',
        token: query.token
      },
      onSubmit: async values => {
        try {
          await resetPasswordMutation(values);
        } catch (error) {
          if (error.name === 'ResetPasswordError') {
            return {
              [app_core_components_Form__WEBPACK_IMPORTED_MODULE_6__/* .FORM_ERROR */ .C]: error.message
            };
          } else {
            return {
              [app_core_components_Form__WEBPACK_IMPORTED_MODULE_6__/* .FORM_ERROR */ .C]: 'Sorry, we had an unexpected error. Please try again.'
            };
          }
        }
      },
      children: [/*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx(app_core_components_LabeledTextField__WEBPACK_IMPORTED_MODULE_5__/* .LabeledTextField */ .I, {
        name: "password",
        label: "New Password",
        type: "password"
      }), /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_10__.jsx(app_core_components_LabeledTextField__WEBPACK_IMPORTED_MODULE_5__/* .LabeledTextField */ .I, {
        name: "passwordConfirmation",
        label: "Confirm New Password",
        type: "password"
      })]
    })]
  });
};

What are detailed steps to reproduce this?

  1. I am working on a repro, but I am not sure how to create a repro. Because even if I use a global 0.41.1 blitz version and create a new project, it still comes bundled with the 0.42 version.

Run blitz -v and paste the output here:

macOS Big Sur | darwin-x64 | Node: v14.16.1

blitz: 0.42.0 (local)

  Package manager: yarn 
  System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 39.76 GB / 64.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 6.14.12 - /usr/local/bin/npm
    Watchman: 2021.10.11.00 - /usr/local/bin/watchman
  npmPackages:
    @prisma/client: 3.4.0 => 3.4.0 
    blitz: 0.42.0 => 0.42.0 
    prisma: 3.4.0 => 3.4.0 
    react: alpha => 18.0.0-alpha-4298ddbc5-20211023 
    react-dom: alpha => 18.0.0-alpha-4298ddbc5-20211023 
    typescript: 4.4.4 => 4.4.4 

Please include below any other applicable logs and screenshots that show your problem:

No response

beerose commented 2 years ago

Did you try to delete .next folder and run the build command again?

JohannesKlauss commented 2 years ago

Yes I tried, it is still happening. Also happening on the deployment pipeline which doesn't hold the .next folder.

flybayer commented 2 years ago

Well I can reproduce this in my client's app, but I can't in a brand new app.

This is very odd. I'm investigating.

flybayer commented 2 years ago

Fixed in https://github.com/blitz-js/blitz/releases/tag/v0.42.1