You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to log every page view to some external storage.
Instead of copy-pasting logging event to every route, I found pretty handy to use router event emminting. It supports "onBeforeLoad" event. Which is called on every page transition.
the problem is, the logEvent is a server function and it tryies to set a set-cookie header. import { setCookie } from "vinxi/http";
But it seems page route does not wait for those subscribe events. And starts to stream response right away. So Im getting: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
If you think there is a better place for loggin, Im happily listening.
Which project does this relate to?
Start
Describe the bug
I want to log every page view to some external storage.
Instead of copy-pasting logging event to every route, I found pretty handy to use router event emminting. It supports "onBeforeLoad" event. Which is called on every page transition.
Code:
the problem is, the
logEvent
is a server function and it tryies to set a set-cookie header.import { setCookie } from "vinxi/http";
But it seems page route does not wait for those subscribe events. And starts to stream response right away. So Im getting:
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
If you think there is a better place for loggin, Im happily listening.
Your Example Website or App
https://github.com/ondrejvelisek/peoples-budget/blob/main/app/router.tsx
Steps to Reproduce the Bug or Issue
Expected behavior
Page route should wait for asynchronous subscribed event handlers.
Screenshots or Videos
Platform
Additional context
It worked in "@tanstack/start": "^1.73.1" but not working in "@tanstack/start": "^1.82.6".
The bug is on Node but not see it on Bun.
The text was updated successfully, but these errors were encountered: