Repository navigation
Conversation
size-limit report 📦Compared: 6b4fa76 (PR test merge using develop at a1162e3) Against: a1162e3 (develop) · base run #65032 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 6 not successful, 49 successful. See the run.
Successful checks
|
651bd2c to
3907e5e
Compare
…he runtimes Matching and answering helpers for the tunnel `serveTunnelIntegration` serves, which never throw into the server, the `intercept` option, and the managed tunnel state on the global carrier so every copy of core sees it. Tunnel requests record no span, session or request data.
cc77ce5 to
f70a9da
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f70a9da. Configure here.
|
|
||
| if (!client || !markRequest(request)) { | ||
| // Tunnel requests get no isolation scope, session or span, whether the SDK or the app answers them. | ||
| if (!client || isServedTunnelRequest(request) || !markRequest(request)) { |
There was a problem hiding this comment.
Tunnel skip pollutes default isolation scope
Medium Severity
Skipping isolation-scope setup for served tunnel requests leaves those requests on the default isolation scope. Until runtime intercept is wired, the app still handles them, so middleware that calls setUser or setTag can leak that data onto the default scope. The next request clones that scope and can inherit the wrong user or tags.
Reviewed by Cursor Bugbot for commit f70a9da. Configure here.
| } | ||
|
|
||
| return originalEmit.call(this, event, ...data); | ||
| } as HttpServer['emit']; |
There was a problem hiding this comment.
Tunnel emit wrap is not restored
Medium Severity
instrumentTunnelServer wraps server.emit only once and then ignores that server forever. If anything later replaces emit (NestJS is known to fork it), HTTP instrumentation re-wraps the replacement but the tunnel interceptor does not, so tunnel requests start reaching the app again.
Reviewed by Cursor Bugbot for commit f70a9da. Configure here.
| export function getServedTunnelMatch(request: TunnelRequestLike): ServedTunnel | undefined { | ||
| const servedTunnel = matchServedTunnel(request); | ||
|
|
||
| return servedTunnel?.intercept ? servedTunnel : undefined; |
There was a problem hiding this comment.
Intercept false 404s React Router tunnel
Medium Severity
handleServedTunnelRequest now returns undefined when intercept is false, but React Router still registers dedicated tunnel routes whose action maps that undefined to a 404. Users who turn intercept off to serve the tunnel themselves get 404s on the tunnel path instead of reaching their handler.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f70a9da. Configure here.
| } finally { | ||
| config.onDone?.(response); | ||
| } | ||
| } |
There was a problem hiding this comment.
Tunnel check ignores provided client
Low Severity
This is more an "is this necessary" check than a hard violation: the new isServedTunnelRequest call uses getClient() internally even though wrapServerRequestHandler already has config.client. On Cloudflare, this wrapper exists specifically because getClient() can miss the per-request client, so tunnel requests may still get sessions, spans, and body capture.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit f70a9da. Configure here.


These series of PRs re-work the new tunnel implementation a second time, it acts as improvement because none of the changes are breaking.
What's different?
The new approach here, sets us up to intercept the tunnel request on the runtime level. This means it is much earlier than the current middleware approach, the tunnel request shouldn't hit the user application at all.
This allows the
serveTunnelIntegrationto be able to set up the tunnel handling on its own without requiring the user to add a manual handler on their own.For frameworks it doesn't change much, but for arbitrary server setups, it becomes much easier:
There is no need to setup routes or handlers unless the user explicity turns it off by either not using the integration or by turning the interception off.
This PR
This PR adds primitive utilities and adjusts the API in a way to make it setup the changes up the stack.