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(rerouting): attempt without middleware #8814

Merged
merged 9 commits into from
Oct 18, 2023
Merged

Conversation

lilnasy
Copy link
Contributor

@lilnasy lilnasy commented Oct 11, 2023

Changes

Testing

Added a case to middleware.test.js.

Docs

Does not affect usage.

@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2023

🦋 Changeset detected

Latest commit: 4242c68

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Oct 11, 2023
@lilnasy lilnasy marked this pull request as ready for review October 12, 2023 01:19
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Thanks for the fix

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this change should be part of the App pipeline because it's in charge of running the middleware, so we should only expose the functions to or not run it.

Also, App is used by other adapters, so we should bump all those adapters that use App:

  • node
  • vercel
  • cloudflare
  • netlify

.changeset/shaggy-onions-try.md Outdated Show resolved Hide resolved
packages/astro/src/core/app/index.ts Outdated Show resolved Hide resolved
packages/astro/src/core/app/index.ts Outdated Show resolved Hide resolved
@lilnasy
Copy link
Contributor Author

lilnasy commented Oct 12, 2023

I was under the impression that the changes made here were all to internal APIs. I'll take another look later.

@lilnasy lilnasy marked this pull request as draft October 12, 2023 14:55
@ematipico
Copy link
Member

I was under the impression that the changes made here were all to internal APIs. I'll take another look later.

Unfortunately no. https://docs.astro.build/en/reference/adapter-reference/#astroapp

Search for import { App } from 'astro/app';, and you'll find that most of our adapters will inherit this fix.

@lilnasy
Copy link
Contributor Author

lilnasy commented Oct 12, 2023

but I have made no changes to the public interface of app

@ematipico
Copy link
Member

ematipico commented Oct 13, 2023

but I have made no changes to the public interface of app

True, although I think that all the consumers of this fix will benefit from it, so we should bump a patch for them too.

@lilnasy
Copy link
Contributor Author

lilnasy commented Oct 13, 2023

In its current state, the fix would apply to adapters and all their versions retroactively; a bump souldn't be necessary. But maybe I am misunderstanding.

Is the idea is to allow the adapter to say whether middleware should run?

app.renderWithOptions(request, { runMiddleware: false })

It would expand the scope of this PR from a bugfix to a feature.

FWIW, it is already planned for the reroute API, and you can see the implementation in the exploration branch.

@ematipico
Copy link
Member

ematipico commented Oct 13, 2023

In its current state, the fix would apply to adapters and all their versions retroactively; a bump souldn't be necessary. But maybe I am misunderstanding.

Yeah you're right, I misunderstood things. Sorry for bikeshedding this. A patch for core should be enough.

@lilnasy
Copy link
Contributor Author

lilnasy commented Oct 13, 2023

No worries. I'll get to the suggestions in a few hours.

@lilnasy lilnasy marked this pull request as ready for review October 13, 2023 14:41
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left some feedback and question.

packages/astro/src/core/app/index.ts Outdated Show resolved Hide resolved
packages/astro/src/core/app/index.ts Outdated Show resolved Hide resolved
packages/astro/src/core/pipeline.ts Outdated Show resolved Hide resolved
@lilnasy lilnasy merged commit ad2bb91 into withastro:main Oct 18, 2023
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Oct 18, 2023
@lilnasy lilnasy deleted the fix/8797 branch October 19, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

500.astro content is not showing when throwing an error from a middleware
4 participants