Repository navigation
Description
Why?
#448 (fixed for ecc-client-elixir-cloud-registry-service-create by #502) affects the other client components too. They read provider only in firstUpdated(), or handle its changes only in part. Apps that replace the provider, e.g. with one that adds a refreshed token, keep using the old one. Or they lose their provider, or show data from the old one.
We reproduced this on dev with fake providers, in Chromium, Firefox and WebKit, for three of the components (services, WES runs and run). 7 of 8 tests failed. With the change below, all of them pass, and so do the existing WES tests. The other components share the same code. We read them but haven't run them.
| Components | Problem on dev |
|---|---|
service-registry services and service, DRS objects, TRS tools, TRS filer tool-create |
Ignore changes of provider. A provider set after the first render (without baseUrl) is never used. A baseUrl change replaces a custom provider. |
DRS object, TRS tool, WES run and run-create, DRS filer object-create |
Removing provider leaves no provider instead of falling back to baseUrl. |
WES runs |
A baseUrl change replaces a custom provider. |
| All of the above | A late answer from a replaced provider overwrites the new provider's data. No component ignores it. |
What?
- Move the provider handling of fix(cloud-registry): react to provider changes #502 into one reusable Lit
ReactiveControllerin@elixir-cloud/design. All client packages depend on that package already, so this needs no new package. The controller:- uses
provider, else a REST provider forbaseUrl(one per URL); - checks this before each update, and calls the component's reload when it changes;
- offers
isCurrent(provider), so that requests drop the answers of a replaced provider.
- uses
- Export it, e.g. as
@elixir-cloud/design/controllers/*. The build currently bundlescomponents/**only. - Use it in all components above, and in
ecc-client-elixir-cloud-registry-service-createinstead of fix(cloud-registry): react to provider changes #502's own code. - Tests for each component:
- a replaced provider is used;
- a provider set after the first render is used;
- a
baseUrlchange keeps a custom provider; - removing the provider falls back to
baseUrl; - a late answer from a replaced provider is ignored.
Sketch of the controller (from our spike)
import type { ReactiveController, ReactiveControllerHost } from "lit";
export interface ProviderHost<P> extends ReactiveControllerHost {
provider?: P;
baseUrl: string;
}
export class ProviderController<P extends object> implements ReactiveController {
current: P | null = null;
private rest: { baseUrl: string; provider: P } | null = null;
constructor(
private readonly host: ProviderHost<P>,
private readonly createRest: (baseUrl: string) => P,
private readonly onChange: (provider: P | null) => void
) {
host.addController(this);
}
// before each render, so that it already uses the new provider
hostUpdate(): void {
const provider = this.resolve();
if (provider === this.current) return;
this.current = provider;
this.onChange(provider);
}
isCurrent(provider: P): boolean {
return provider === this.current;
}
private resolve(): P | null {
const { provider, baseUrl } = this.host;
if (!baseUrl) {
this.rest = null;
} else if (this.rest?.baseUrl !== baseUrl) {
this.rest = { baseUrl, provider: this.createRest(baseUrl) };
}
return provider ?? this.rest?.provider ?? null;
}
}Components then load with const provider = this.providers.current and return early after each await if !this.providers.isCurrent(provider). Comparing providers misses the case where a provider comes back (A → B → A). #502's request counter covers that case, so it may be worth keeping.
Out of scope
- The TES components (
ecc-client-ga4gh-tes-*) have no provider at all: they takebaseURLand call API functions directly, so apps can't add a token to their requests. That needs a separate issue.
Acceptance criteria
- In every client component with a
providerproperty, setting, replacing or removingproviderorbaseUrlat any time makes all later requests useprovider, else a REST provider forbaseUrl. provideralways takes precedence overbaseUrl.- Answers from a replaced provider are ignored.
- Tests cover this for each component.
Activity
uniqueg commentedon Nov 18, 2026
One more case for the controller: Sourcery found it on #596 and #597, and it applies to every component that handles provider changes today (at least
servicesandservicefrom #577, andservice-typesandservice-infofrom #596 and #597).A load checks whether its provider is still current by comparing it with the provider the component resolved in its last update. Between setting
providerorbaseUrland Lit's next update (one microtask), that resolved provider is still the old one. A load from the old registry that settles in that window still applies its data and emits it; the reload starts right after and replaces it, so apps briefly see data of the old registry.Suggested fix in the controller: let
isCurrent(provider)resolve the provider from the currentproviderandbaseUrlproperties instead of returningprovider === this.current. Invalidating pending loads in a property setter instead would leave the component loading forever if the property is changed and changed back before the update.Test for each component: replace the provider, settle the old provider's request before the next update (e.g. resolve it synchronously after setting the property), and check that its data is neither shown nor emitted.