Skip to content

fix: static pages not rendered with fastify after v9.5#15469

Closed
fkatsuhiro wants to merge 2 commits intowithastro:mainfrom
fkatsuhiro:fix/node-middleware-static-routes
Closed

fix: static pages not rendered with fastify after v9.5#15469
fkatsuhiro wants to merge 2 commits intowithastro:mainfrom
fkatsuhiro:fix/node-middleware-static-routes

Conversation

@fkatsuhiro
Copy link
Contributor

Changes

issue: #15467

cause:
With the upgrade to Node.js v9.5, a change was introduced in the conditional branching, causing statically built endpoints to be incorrectly routed to SSR processing, resulting in errors due to no executable page function being found.

change:
Changed the relevant conditional statement.

routeData && !(routeData.type === 'page' && routeData.prerender)

routeData && (routeData.type === 'redirect' || !routeData.prerender)

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 7fbe2d5

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: integration Related to any renderer integration (scope) label Feb 10, 2026
@ematipico ematipico added the pr preview Apply this label to a PR to generate a preview release label Feb 12, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 12, 2026

npm i https://pkg.pr.new/@astrojs/node@15469

commit: 7fbe2d5

@matthewp
Copy link
Contributor

Can you add a test? The condition here doesn't seem to have anything to do with Fastify. What's the underlying problem?

@fkatsuhiro
Copy link
Contributor Author

fkatsuhiro commented Feb 13, 2026

@matthewp Thank you for your reply. I had checked comments of #15467.

The original reason for this implementation was a concern regarding the rendering process. Upon comparing the current server-app.ts with version 9.4.6, I noticed that new conditions for pre-rendering had been added. I suspected that !routeData.type === 'page' was the root cause of the error, so I decided to relax the conditions in this implementation.

But now I understood cause of this issue. and I noticed my mistake....

While node v9.5.0 ~ v10.00 -alpha,

const routeData = app.match(request, true);
if (routeData) {
const response = await als.run(request.url, () =>
app.render(request, {
addCookieHeader: true,
locals,
routeData,
prerenderedErrorPageFetch,
}),
);
await NodeApp.writeResponse(response, res);
} else if (next) {

here
const routeData = app.match(request, true); : this code made initial state of routeData is true. This is the actually cause I think....

But it has been improved already node v 10.0.0 - beta, maybe no problem...

So, my PR no need to reflect for solving this issue.Should I close this PR? Or would you like me to create a test case for this specific issue instead?

@matthewp
Copy link
Contributor

Close the PR if your issue is already fixed

@fkatsuhiro
Copy link
Contributor Author

Okay. I'll close this PR.

@fkatsuhiro fkatsuhiro closed this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope) pr preview Apply this label to a PR to generate a preview release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants