Skip to content

Duplicate tRPC request during SSR #1698

Open
@DevWedeloper

Description

@DevWedeloper

Please provide the environment you discovered this bug in.

"dependencies": {
  "@analogjs/router": "^1.15.1",
  "@analogjs/trpc": "^0.3.0",
  "@angular/animations": "^19.0.0",
  "@angular/common": "^19.0.0",
  "@angular/compiler": "^19.0.0",
  "@angular/core": "^19.0.0",
  "@angular/forms": "^19.0.0",
  "@angular/platform-browser": "^19.0.0",
  "@angular/platform-browser-dynamic": "^19.0.0",
  "@angular/platform-server": "^19.0.0",
  "@angular/router": "^19.0.0",
  "@trpc/client": "^10.45.2",
  "@trpc/server": "^10.45.2",
  "rxjs": "~7.8.0",
  "tslib": "^2.3.0",
  "zone.js": "~0.15.0"
},
"devDependencies": {
  "@analogjs/platform": "^1.15.1",
  "@analogjs/vite-plugin-angular": "^1.15.1",
  "@analogjs/vitest-angular": "^1.15.1",
  "@angular-devkit/build-angular": "^19.0.0",
  "@angular/build": "^19.0.0",
  "@angular/cli": "^19.0.0",
  "@angular/compiler-cli": "^19.0.0",
  "jsdom": "^22.0.0",
  "typescript": "~5.8.0",
  "vite": "^6.0.0",
  "vite-tsconfig-paths": "^4.2.0",
  "vitest": "^3.0.0"
}

Which area/package is the issue in?

trpc

Description

When using analogjs/trpc, a tRPC get (query) request made during SSR results in two calls: one on the server and one again on the client. This doesn't happen when using HttpClient.

Please provide the exception or error you saw

Two requests are made, one on the server, and one again on the client.

Other information

Work Around

Using pendingUntilEvent() can prevent the duplicate request by blocking application stability until the data is loaded. However, this feels unintuitive and might not be desirable in all scenarios—especially when some data shouldn't delay the app becoming stable.

Minimal reproduction

https://github.com/DevWedeloper/analog-trpc-ssr-double-fetch

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions