Skip to content

Route head function not called if rendering notFoundComponent #3657

Closed
@GregoryCollett

Description

@GregoryCollett

Which project does this relate to?

Router

Describe the bug

Note:
we are attempting to bump from 1.86.1 to 1.112.11

Context:
We are running our own SSR server and have not yet migrated to start BUT the repro provided is using start.

The issue only occurs on SSR (test case is simulating google bot/crawlers without JS)

I have a case where we have a head fn on a route that can provide meta data for both matched or notFound depending on the data return from loaderData. The notFound is thrown from a child route and bubbles up as I would expect it to BUT the head fn on the route is no longer called as I would expect. This is only an issue when we are rendering the notFoundComponent, the standard use case still works as expected.

This had been working previously without issues. Any advice?

Your Example Website or App

https://github.com/GregoryCollett/tanstack-ssr-head-bug

Steps to Reproduce the Bug or Issue

  • Run app
  • Set network conditions to simulate google bot
  • Disable Javascript
  • Go to posts
  • Navigate through posts and see the title is changing as expected
  • Navigate through to non-existing-post and see the meta data is not updated as expected and the head function is not called.

Expected behavior

As a developer, I expect the head function to be called so that I can render relevant meta data but I am seeing that the head function is not called at all meaning I cannot output relevant meta data e.g. Post not found

Screenshots or Videos

No response

Platform

  • OS: ALL
  • Browser: ALL
  • Version: N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions