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(nuxt): allow modules to disable appManifest without crashing #24786

Merged
merged 9 commits into from Dec 16, 2023
Merged

fix(nuxt): allow modules to disable appManifest without crashing #24786

merged 9 commits into from Dec 16, 2023

Conversation

IonianPlayboy
Copy link
Contributor

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves #24672

nuxt.options.experimental.appManifest is set to true by default, and can be set to false by users if they want to opt out of the app manifest generation feature. However, a user module trying to disable appManifest would break completely the user app because of the ordering in initNuxt (located in packages/nuxt/src/core/nuxt.ts).

Before this PR, the manifest-route-rule middleware was added before any user module could have the opportunity to set nuxt.options.experimental.appManifest to false. However, the middleware throws an error if it is registered and appManifest is not equal to true.

As a result, when a user module tried to override the Nuxt config to set nuxt.options.experimental.appManifest to false, the middleware was still registered in the app but was throwing on every route with a 500 error, thus broking the app.

This is why this PR moves the addition of the manifest-route-rule middleware after the registration of user hooks : this way, the config can be altered by the user modules before the middleware is added.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Dec 15, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions bot added the 3.x label Dec 15, 2023
@IonianPlayboy IonianPlayboy changed the title fix(core): allow modules to disable appManifest without crashing fix(nuxt): allow modules to disable appManifest without crashing Dec 15, 2023
@IonianPlayboy
Copy link
Contributor Author

For the record, I tried to add a test to cover this bug for the future, but I was not sure how exactly the test setup worked and I did not find the time to dive further into it. If this is something you consider worthwile for this PR, I would appreciate some guidance about how to do it.

packages/nuxt/src/core/nuxt.ts Outdated Show resolved Hide resolved
packages/nuxt/src/core/nuxt.ts Show resolved Hide resolved
packages/nuxt/src/core/nuxt.ts Show resolved Hide resolved
packages/nuxt/src/core/nuxt.ts Outdated Show resolved Hide resolved
packages/nuxt/src/core/nuxt.ts Outdated Show resolved Hide resolved
@danielroe
Copy link
Member

Sorry about all the spam - just making a one line change on my phone πŸ˜…

@danielroe danielroe merged commit 6f3cf42 into nuxt:main Dec 16, 2023
34 checks passed
@github-actions github-actions bot mentioned this pull request Dec 16, 2023
@IonianPlayboy IonianPlayboy deleted the fix/disabling-app-manifest-module branch December 16, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabling experimental.appManifest in a module breaks the app
2 participants