Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: getAgent documentation clarification #1464

Open
1 of 6 tasks
Roaders opened this issue Dec 10, 2024 · 2 comments
Open
1 of 6 tasks

Question: getAgent documentation clarification #1464

Roaders opened this issue Dec 10, 2024 · 2 comments
Assignees
Labels
Milestone

Comments

@Roaders
Copy link
Contributor

Roaders commented Dec 10, 2024

Question Area

  • App Directory
  • API
  • Context Data
  • Intents
  • Use Cases
  • Other

Question

On a discussion with @kriswest and @robmoffat it became clear to me that the implementation of getAgent will return a cached promise for any subsequent calls that are made to it. This should probably be documented along with the potentially unexpected behavior where any parameters passed to the function are ignored after the first call.

@kriswest also said that the case where getAgent fails and is then called again that the promise should be cleared and another attempt made.

@Roaders Roaders added the question Further information is requested label Dec 10, 2024
@kriswest kriswest added docs Documentation FDC3 for Web Browsers and removed question Further information is requested labels Dec 10, 2024
@kriswest kriswest self-assigned this Dec 10, 2024
@kriswest kriswest added this to the 2.2 milestone Dec 10, 2024
@kriswest
Copy link
Contributor

I'll look into documenting this - the latter point (clearing the cached promise on error) has already been implemented and appears to work well. On the former point, given that only a single agent can be in scope for a window for either the Desktop Agent Preload or Desktop Agent Proxy interfaces (as they are currently defined) we only really have three options:

  1. Allow multiple calls, taking the arguments from the first call only and responding to all calls with the same promise
  2. Allow only a single call and define an error to return on subsequent cals
  3. (Hybrid of previous approaches) Allow multiple calls, but check that the arguments match the first call made, return the same promise for each call if they do, return an error if they do not.

At present the implementation uses the first approach. This could easily be augmented with a log message on subsequent calls to make it clear whats happening.

@Roaders are you happy for us to proceed with 1. (+ a log message)?

@Roaders
Copy link
Contributor Author

Roaders commented Dec 13, 2024

I don't like 2 or 3. I think it would be normal to have many places in an app that will call getAgent() - that's certainly how we intend to use it.

The way I have implemented it is I log a warning if params have been passed but we're ignoring them. The expected use is that the first call will configure it - with a fallback for example - and subsequent calls will get the same promise as was returned when the initial params were passed.

I would consider a log every subsequent time getAgent() is called as noise that's not really necessary (but am not arguing against if you want to add one) but a log when parameters are ignored is useful.

I hope that makes sense,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants