Skip to content

Keep warm frp work connections for bb connect next - #6207

Merged
ymichael merged 1 commit into
mainfrom
bb/warm-frpc-work-connection-pool-thr_wy34qwcn2h
Oct 26, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/warm-frpc-work-connection-pool-thr_wy34qwcn2h

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

buildFrpcConfig (packages/frp-client/src/config.ts) never set transport.poolCount, so it defaulted to 0 and frps kept no idle work connections for bb connect next. In frp v0.71.0 (the version pinned in packages/tunnel-contract/src/next.ts), server/control.go GetWorkConn handles an empty pool by sending ReqWorkConn and waiting for frpc to dial a connection, which costs an extra round trip. After every take it sends another ReqWorkConn to replenish. frps's vhost HTTP proxy keeps only MaxIdleConnsPerHost: 5, so a burst of more than 5 parallel requests needs new work connections. One example is the web app refetching every active query when a tab resumes. Each of those requests waits a round trip, and the replenish requests then overflow the poolCount + 10 work-conn channel. RegisterWorkConn rejects the extra connections, and frpc logs this as StartWorkConn contains error: work connection pool is full, discarding. The user's server log showed 16–21 of these per burst on 2026-10-23.

What changed

  • buildFrpcConfig now sets transport.poolCount: 10. That is the gate's maxPoolCount (apps/connect-next/src/frps.ts), so frps uses the full value instead of clamping it. frps now pre-requests 10 work connections at login and keeps the pool full, and the channel capacity grows to 20, which covers the bursts we observed. frp multiplexes work connections as streams over the existing control connection by default, so idle pooled connections are cheap.
  • Logging is unchanged. The plugin already forwards every frpc line at info level (packages/frp-client/src/supervisor.ts onLine). Fewer of these lines should appear now, and lowering the level for one benign message doesn't seem worth a special case.
  • No wire or CLI changes.

How you verified

  • pnpm exec turbo run test typecheck --filter=@bb/frp-client --filter=./plugins/connect-next: all passing (frp-client 40 tests; connect-next 28 tests, including frp-e2e.test.ts, which launches the real frps/frpc binaries with the generated config and tunnels requests through it).
  • Updated the exact-config assertion in packages/frp-client/test/config.test.ts.

AGENT GENERATED

🤖 Generated with Claude Code

buildFrpcConfig never set transport.poolCount, so frps held no idle work
connections: each request beyond the vhost proxy's 5 idle connections
waited for a ReqWorkConn round trip, and the replenish requests from a
burst overflowed the poolCount+10 channel, which frpc logged as "work
connection pool is full, discarding". Request 10 pooled connections, the
gate's maxPoolCount.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 536a6ba into main Oct 26, 2026
33 checks passed
@ymichael
ymichael deleted the bb/warm-frpc-work-connection-pool-thr_wy34qwcn2h branch October 26, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant