Skip to content

Conversation

@kevineger
Copy link

Initially, I set out to fix a logging bug; if the HTTP attempt (no custom fetch) failed but the custom fetch succeeded, the HTTP error would still be logged. After making that fix, I came to the opinion that it likely makes more sense to first try the custom fetch and then fallback. Otherwise we're issuing a ton of redundant requests.

This change also:

  • Removes some duplication by lifting the two private getWidgetScriptSource* methods to an abstracted downloadFile function.
  • Simplifies the logging. Previously the errors included from ([httpclient|fetch]) and the relevant ex. This duplicated the context (httpclient vs. fetch). Since the inner error contains this info, we can use the same top level error message when we log.

With minimal context of the existing code, I can't easily determine... but for reviewers with more background:

  1. When would using the custom fetch ever fail?
  2. Do we even need the fallback, or would it make more sense to strictly rely on the custom fetch?
  3. Is the fallback behaviour I'm proposing here desirable or would you still prefer we issue both requests simultaneously and I instead change this PR to only log errors if both fail?

I looked to write or modify a unit test, but the RemoteIPyWidgetScriptManager doesn't appear to have existing coverage. If reviewers feel the change necessitates a test, I can look to cover the component. Though IMO that's out of scope given the precedent.

Initially, I set out to fix a logging bug; if the HTTP failed but the custom fetch succeeded, the HTTP error would still be logged. After making that fix, I realized that the logic should maybe be tweaked a bit to instead first try with the custom fetch, then fallback to without.

With minimal context of the existing code, I can't easily determine... but for reviewers with more background, when would using the custom fetch ever fail? Do we even need the fallback? Is the fallback behaviour I'm proposing here desireable or would you still prefer we issue both requests simultaneously and I instead change this PR to only log errors if both fail?

I looked to write or modify a test, but the `RemoteIPyWidgetScriptManager` doesn't appear to have existing unit test coverage. If reviewers feel the change necessitates a test, I can look to cover the component. Though that's likely a bit out of scope.
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