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
refactor: pipeline lifetime #9795
Conversation
🦋 Changeset detectedLatest commit: a6cf337 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 |
e2e71ee
to
a438f62
Compare
a438f62
to
2532860
Compare
1ddd87d
to
7763d76
Compare
* An environment represents the static parts of rendering that do not change | ||
* between requests. These are mostly known when the server first starts up and do not change. | ||
* Thus, they can be created once and passed through to renderPage on each request. | ||
* The environment represents the static parts of rendering that do not change between requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The environment represents the static parts of rendering that do not change between requests. | |
* The environment represents the static parts of rendering that do not change among requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original seems correct.
super(logger, manifest, mode, [], resolve, serverLike, streaming, routeCache); | ||
} | ||
|
||
async preload(filePath: URL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not new code. It is brought in from https://github.com/withastro/astro/blob/astro@4.3.5/packages/astro/src/vite-plugin-astro-server/index.ts#L7. I don't have the context to document it.
packages/astro/src/core/pipeline.ts
Outdated
env: Readonly<Environment>, | ||
mod: Readonly<ComponentInstance> | undefined, | ||
onRequest?: MiddlewareHandler | ||
async renderRoute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the docs are outdated now, because it seems that this function doesn't throw any error anymore? We should update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know when that behavior changed?
7f7be82
to
8298c38
Compare
I can address the code style comments at the end of the review cycle. Do you have any comments on the overall direction. To summarise, half of |
The direction seems reasonable to me; I have some thoughts:
|
8298c38
to
0fd887d
Compare
That's a good idea. |
fa846cf
to
71af134
Compare
`environment.ts` is now lives directly in `src/core`, rather than `src/core/render`. `environment.createPipeline` is removed. `Pipeline.create` is used instead. Constructors with positional arguments are replaced by `Environment.create` with named arguments. Clarifies the use of `HiddenPipeline`.
71af134
to
a6cf337
Compare
Changes
Pipeline
lasted the entire duration of a server while being concerned with only the request.RenderContext
as the hub of rendering by bringing control over creating other downstream objects, and rendering to it.Environment
is rolled intoPipeline
, which now also exposes functions to retrieve styles and scripts forRenderContext
to use.RenderContext
is now in a sturdier position to take on the complexity of shiftingRouteData
during the course of middleware chain execution.render-context.ts
Testing
Future
routeData.type
could go away. Differences between endpoint, pages, redirects, and fallbacks could be handled by the compiled page chunks themselves. It would be easy to create a standardssrEntry
format that exports aRenderContext
->Response
function.renderPage
would not have to be included if all pages are prerendered and onlyssrEntry
s for endpoints remain.next()
, giving the middleware chain the opportunity to changerouteData
, and "reroute" the request.