Skip to content

pnpm test:docs reports 27 broken links on Windows because verify-links.ts assumes forward slashes #11177

Description

@yogesh968

Describe the bug

pnpm test:docs fails on Windows with 27 broken links that are all fine. Every one of them is a documentation link pointing at an example.

scripts/verify-links.ts builds the target path with path.resolve, which uses the platform separator, and then matches that path against patterns written with forward slashes:

https://github.com/TanStack/query/blob/main/scripts/verify-links.ts#L56-L68

const isExample = absPath.includes('/examples/')

if (isExample) {
  absPath = absPath.replace(
    /\/docs\/framework\/([^/]+)\/examples\//,
    '/examples/$1/',
  )
  exists = existsSync(absPath) && statSync(absPath).isDirectory()
}

On Windows absPath is C:\Users\...\docs\framework\react\examples\simple, so includes('/examples/') is false. The example branch never runs, the path is never rewritten to examples/react/simple, and the link is looked up as a markdown file that does not exist.

CI does not catch this because it runs on Linux.

Your minimal, reproducible example

Clone the repository on Windows and run the script directly:

pnpm install
node scripts/verify-links.ts

Steps to reproduce

  1. Clone the repository on Windows.
  2. Run pnpm install.
  3. Run node scripts/verify-links.ts (or pnpm test:docs).

Output:

Found 494 markdown files

❌ Found 27 broken links:
docs/framework/lit/quick-start.md
  link:      ./examples/basic
  resolved:  C:\Users\...\query\docs\framework\lit\examples\basic.md
  why:       Not found
...

The resolved path in the report shows the problem directly: it still points into docs/framework/lit/examples/ instead of examples/lit/.

Expected behavior

The check should pass on Windows just as it does on CI, so contributors can run pnpm test:docs locally before pushing. CONTRIBUTING.md points people at these commands.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Windows 11
  • Node: 24.11.1
  • pnpm: 11.9.0

Tanstack Query adapter

None

TanStack Query version

current main

TypeScript version

5.9.3

Additional context

CONTRIBUTING.md does note that the repository uses symlink based configuration and recommends WSL, but this script does not need symlinks and works fine once the separators are normalized. Fix and PR coming.

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