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(server): skipped for ended response #5230

Merged
merged 2 commits into from
Oct 9, 2021
Merged

Conversation

antfu
Copy link
Member

@antfu antfu commented Oct 8, 2021

Description

In middleware mode, or with plugins that interact with the dev server, the request might be handled before Vite sending them out (in our case, the Nuxt integration, nuxt/nuxt#11881). This result error:

Cannot set headers after they are sent to the client

This PR makes the server skip closed response.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes nuxt/framework#123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@pi0 pi0 mentioned this pull request Jan 19, 2023
2 tasks
patak-dev
patak-dev previously approved these changes Oct 8, 2021
@patak-dev
Copy link
Member

Should we also check before to avoid doing unnecessary work? For example, before going through the pipeline, or when this middleware quicks in?

html = await server.transformIndexHtml(url, html, req.originalUrl)

@antfu antfu merged commit 7255fd5 into vitejs:main Oct 9, 2021
@antfu antfu deleted the fix/res-end branch October 9, 2021 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants