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

fix: use express body-parser reexports #14443

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

Phillip9587
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

@nestjs/platform-express depends on [email protected] and on [email protected]. Express 5.0.1 itself depends on [email protected] and reexports its middlewares. So 2 different versions of body-parser are installed and used.

What is the new behavior?

nestjs/platfrom-express depends only on [email protected] and uses the body-parser reexports. They are not deprecated and will not be removed! See: https://github.com/expressjs/express/blob/master/lib/express.js#L77-L81

It was already proposed in #8645 a while ago.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

Pull Request Test Coverage Report for Build 338c9135-4f3b-41e4-9c5f-0e04c2cf04dd

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.696%

Totals Coverage Status
Change from base Build fc27da9d-2a1e-4b8b-ac32-cb20670b91ce: 0.0%
Covered Lines: 7103
Relevant Lines: 7919

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit 4304b48 into nestjs:master Jan 20, 2025
2 of 3 checks passed
@kamilmysliwiec
Copy link
Member

LGTM

@kamilmysliwiec
Copy link
Member

This change caused a regression for GraphQL users nestjs/graphql#3451

@kamilmysliwiec
Copy link
Member

Current version:

image

Previous version:

image

Any chance we could have the original behavior available under a flag? (through config object) @Phillip9587 Otherwise, we might need to revert to the previous version

@kamilmysliwiec
Copy link
Member

Alternatively, we could register the following middleware:

app.use((req, res, next) => {
 req.body = req.body ?? {};
 next();
});

only for the /graphql route

@Phillip9587
Copy link
Contributor Author

I am currently out of the office for the next two weeks. If nobody is available to address this in the meantime, we can consider reverting the change temporarily to avoid potential issues. I like the second approach and will work on the fix as soon as I return from my holiday.

@kamilmysliwiec
Copy link
Member

Workaround commit nestjs/graphql@1496adc

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

Successfully merging this pull request may close these issues.

3 participants