Skip to content

fix: carry the connection name onto builders created from a bound ins… - #5

Merged
jayjfletcher merged 1 commit into
mainfrom
fix/propagate-connection-name
Aug 31, 2026
Merged

fix: carry the connection name onto builders created from a bound ins…#5
jayjfletcher merged 1 commit into
mainfrom
fix/propagate-connection-name

Conversation

@jayjfletcher

Copy link
Copy Markdown
Owner

…tance

connection() clones the Stretch instance and swaps its client, but the factories that build from it — query(), index(), multi(), scroll() — forwarded only the client, never connectionName. The new builder therefore reported the default connection.

Queries still reached the right cluster, so nothing failed loudly. What broke was everything keyed on the name: the response cache key is namespaced by it, so Stretch::connection('b')->index('posts') cached under connection a and two connections holding an identically named index could serve each other's hits.

Propagate the name through a bindConnectionName() setter. A protected property cannot be assigned across unrelated classes even when both use the trait, so the setter is public and marked @internal; connection() remains the only way to switch a connection, which swaps the client too.

Found while tracing a favorites/pins search that reported connection infinity in its cache key while configured for microservices.

…tance

`connection()` clones the Stretch instance and swaps its client, but the
factories that build from it — `query()`, `index()`, `multi()`, `scroll()` —
forwarded only the client, never `connectionName`. The new builder therefore
reported the *default* connection.

Queries still reached the right cluster, so nothing failed loudly. What broke
was everything keyed on the name: the response cache key is namespaced by it,
so `Stretch::connection('b')->index('posts')` cached under connection `a` and
two connections holding an identically named index could serve each other's
hits.

Propagate the name through a `bindConnectionName()` setter. A protected
property cannot be assigned across unrelated classes even when both use the
trait, so the setter is public and marked `@internal`; `connection()` remains
the only way to *switch* a connection, which swaps the client too.

Found while tracing a favorites/pins search that reported connection
`infinity` in its cache key while configured for `microservices`.
@jayjfletcher
jayjfletcher merged commit a29109a into main Aug 31, 2026
2 of 3 checks passed
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