Repository navigation
perf(core): ignore credential events for unrelated integrations - #60782
Conversation
There was a problem hiding this comment.
I found no problems with this change. I checked the publish sites in credential.ts. credential.updated on its own (a label rename, an inactive create or an inactive remove) never changes the active credential or the number of connections. Every create, activate or remove that does change them also publishes credential.switched, including the first and last credential for an integration. The provider snapshot keys connections by ID and ignores labels, so dropping Updated and filtering Switched by integrationID can't hide a real change. The core plugin, provider, credential and integration tests pass (582). typecheck:tsc passes too; the typecheck script itself fails on both base and PR because the installed bun has no check command.
The public API is unchanged: event shapes and publishers stay the same, and only internal subscriptions changed.
Problem
Every Location runs two listeners that wake up on any credential event for any integration:
credentialSettings(Bedrock, both Cloudflare plugins, GitLab) re-reads its integration's active credential on everycredential.updatedandcredential.switched, even when the event is about some other integration. That's 4 listeners doing a list plus a get each, per Location, per event.Providerrunsnotify(snapshot plusintegrations.list(), which reads every credential) on everycredential.updated, even though that event can't change which providers are available.Change
credential.updatedis only published for a create, a label rename or a remove. Any of those that changes the active credential also publishescredential.switched. Soupdatedalone never changes the active credential's value, and never takes an integration from zero connections to some or back.What that buys per Location:
updatedalso fires)I added a test that a Cloudflare Workers AI form login switch still updates the account ID, so the filter doesn't drop its own integration's events.
Out of scope
Providerstill reacts to everycredential.switched, including integrations it has no provider for. Filtering that would mean checking the provider records on each event, and the switch is rare enough that I left it.google-vertex.tsandconfig/plugin/policy.tshave the same unfiltered subscription shape.