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

DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. #6167

Closed
4 of 7 tasks
hasezoey opened this issue Dec 22, 2021 · 12 comments · Fixed by #6168
Closed
4 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@hasezoey
Copy link

hasezoey commented Dec 22, 2021

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Currently, when running docusaurus start, a deprecation warning comes up:

(node:71710) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.

this error comes only when using start, and not build


Note: i did not do the step I have tried the npm run clear or yarn clear command., because no command like yarn clear exists (using yarn version 1.22.17)

Steps to reproduce

  1. create example project (or clone https://github.com/nodkz/mongodb-memory-server and cd into /website)
  2. install docusaurus 2.0.0-beta.14 (either by manually setting it in the package.json or using yarn upgrade --latest @docusaurus/core @docusaurus/preset-classic)
  3. run docusaurus start --no-open --poll

Expected behavior

to not have a deprecation warning

Actual behavior

the mentioned deprecation warning

(its currently just a warning, not breaking anything)

Your environment

in case it matters, i also get some warnings when installing all packages:

info No lockfile found.
[1/4] Resolving packages...
warning @docusaurus/core > webpack-dev-server > url > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@docusaurus/core > react-dev-utils > [email protected]" has unmet peer dependency "typescript@>= 2.7".
warning "@docusaurus/core > @docusaurus/utils > @mdx-js/[email protected]" has incorrect peer dependency "react@^16.13.1".
warning "@docusaurus/preset-classic > @docusaurus/theme-search-algolia > @docusaurus/[email protected]" has unmet peer dependency "prism-react-renderer@^1.2.1".
warning "@docusaurus/preset-classic > @docusaurus/theme-search-algolia > @docsearch/[email protected]" has unmet peer dependency "@types/react@>= 16.8.0 < 18.0.0".
warning "@docusaurus/preset-classic > @docusaurus/theme-search-algolia > @docsearch/react > @algolia/[email protected]" has unmet peer dependency "@algolia/client-search@^4.9.1".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 25.44s.

Reproducible demo

No response

Self-service

  • I'd be willing to fix this bug myself.
@hasezoey hasezoey added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Dec 22, 2021
@slorber
Copy link
Collaborator

slorber commented Dec 22, 2021

Thanks, this seems like a recent change in Webpack: webpack/webpack-dev-server#4068

Should be fixed in the next release with #6168

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Dec 22, 2021
@Josh-Cena
Copy link
Collaborator

@hasezoey Also, do note that yarn clear does exist, it's just that your site is initialized so long ago that this script wasn't included in the template. You can add another "clear": "docusaurus clear" in your package.json's scripts.

@hasezoey
Copy link
Author

hasezoey commented Jan 1, 2022

Also, do note that yarn clear does exist, it's just that your site is initialized so long ago that this script wasn't included in the template.

wouldnt that make it yarn run clear instead of just yarn clear? (from what i know the only script that can omit run is test, didnt try others, but i know that some others like build require subcommand run)

also, if i remember correctly the project where i noticed this issue in, got created with around @docusaurus/[email protected]

You can add another "clear": "docusaurus clear" in your package.json's scripts.

thanks for this note, i did not know this subcommand existed in docusaurus, is there documentation somewhere on what exactly it does?

@Josh-Cena
Copy link
Collaborator

It's yarn clear and npm run clear, because npm demands all custom scripts to be invoked with run but yarn is smart enough to know which scripts are intrinsic and which are external so as long as there's no ambiguity you can drop the run. yarn build doesn't require run either.

also, if i remember correctly the project where i noticed this issue in, got created with around @docusaurus/[email protected]

Yep, docusaurus clear was introduced somewhere after that. You can get the latest list of CLI commands here: https://docusaurus.io/docs/next/cli#docusaurus-cli-commands

@Chasen-Zhang
Copy link

Chasen-Zhang commented Jan 11, 2022

but What is the final solution?
image

@Josh-Cena
Copy link
Collaborator

@Chasen-Zhang The deprecation is just a warning, not an error. Your error is unrelated, which is that localhost is not found. Did you modify your hosts file?

@Chasen-Zhang
Copy link

@Chasen-Zhang The deprecation is just a warning, not an error. Your error is unrelated, which is that localhost is not found. Did you modify your hosts file?

oh thanks, it is my fault, i overwrote my localhost

@Josh-Cena
Copy link
Collaborator

Also, to get rid of the warning, just upgrade to 2.0.0-beta.14

@slorber
Copy link
Collaborator

slorber commented Jan 13, 2022

Also, to get rid of the warning, just upgrade to 2.0.0-beta.14

Just double-checked and it will only be in the next beta.15 release (or canary)

For now you can just ignore this warning, it will disappear soon

@imransilvake
Copy link

Getting the same weird warnings on yarn start.

@S0f0s
Copy link

S0f0s commented Jan 21, 2022

I get the same error when i run my app which just tries to authenticate users for login in through Azure AD. When i try to log-in through my app, the Microsoft popup login window flashes for sec and then dies.

@Josh-Cena
Copy link
Collaborator

@S0f0s Your error is unrelated. If your login doesn't succeed it has nothing to do with Docusaurus.

Everyone, this message is just a WARNING. Webpack dev server doesn't do breaking changes across minor versions so nothing would actually break. The next release would get rid of this message. For now, you can either use canary, or bear with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants