Repository navigation
fix(analytics): write one request line per request, closed or finished - #61
Merged
Merged
Conversation
registerRequestLogging attaches one close listener per response, so a request writes exactly one line with a finished flag, and a response that closes before the app sends a status logs 499. The path is the request target as it arrived, normalised without reading // as a host. A document prerender is kind page with a prerender flag. Static assets are dropped before the caller HMAC is computed. docs/analytics.md describes the line and the account and event export rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The request line (
src/lib/proxy/requestLog.ts) was written only when a response finished, so an abandoned page render, an aborted RSC fetch or a closed/mcpstream wrote nothing.registerRequestLoggingnow attaches onecloselistener to each response athttp.server.request.start, and Node emitscloseafterfinish, so every request writes exactly one line, withfinished: response.writableFinished. A response that closes before the app sends a status logs 499. A request accepted before the subscription starts is logged when it finishes.pathis the request target as it arrived, captured at request start, with dot segments resolved and//mcpkept as a path and not read as a host. An absolute-form target logs its pathname, an unparsable one the raw target cut at?or#, andOPTIONS *logs*. A document request withSec-Purpose: prefetch;prerenderis kindpagewithprerender: true, while RSC fetches and router prefetches keep their kinds. Static assets are dropped before headers are read or the caller HMAC computed. The fields infra'swebsite_requests_dailyreads keep their names and types, andfinishedandprerenderare new.docs/analytics.mddescribes the line, and the export section states theaccount_dailythreshold and theexport_rulesreload, which #60 ships. Merge after #60.Testing: the proxy tests pass (103), including real HTTP servers for finish, early close, a close before headers, a rewritten
request.urland a streamed upload over 10 MiB. Each new test fails without its change.