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

refactor!: Remove Transporter #1937

Merged
merged 9 commits into from
Feb 7, 2025
Merged

refactor!: Remove Transporter #1937

merged 9 commits into from
Feb 7, 2025

Conversation

d-goog
Copy link
Collaborator

@d-goog d-goog commented Feb 5, 2025

Description

The Transporter interface has been a pain-point for customers for years. To highlight a few:

Additionally, this was the primary blocker for Firebase-Admin's adoption for this library:

As Transporter is essentially a wrapper around Gaxios with a few auth-centric methods we can remove this layer of complexity to greatly improve UX.

Testing

As we're removing Transporter unit test coverage has improved with this change.
Additionally, the current integration tests in pass with minimal change.

Impact

With this change we're optimizing the configuration and request flow to reduce complexity:

  • From: Client Libraries -> Auth -> Transporter -> Gaxios
  • To: Client Libraries -> Auth -> Gaxios

Additionally, this will unblock:

  • Auth Metrics (which would benefit from centralized request handling)
  • Debug logging (which would benefit from centralized request handling)
  • gaxios v6 (as it would streamline the PR and make it significantly smaller given we do not have)
  • fetch API Support in Auth (via gaxios v6)

Additional Information

In a separate PR I will draft a migration guide for customers migrating from v9 to v10.

As a TL;DR for migrating:

  • if using Transporter use Gaxios instead, which is conveniently re-exported by this library
  • if passing transporter config no changes are necessary

🦕

@d-goog d-goog requested review from a team as code owners February 5, 2025 22:02
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Feb 5, 2025
Copy link
Contributor

@sofisl sofisl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, a few notes:

  1. The issues linked here don't make it immediately clear to me that we need to remove transporter. Can you help explain how you came to this solution?
  2. It seems like this is just removing transporter. Since that is the case, can we add a warning to the transporter property, and confirm it with a test? If it really is refactoring, can we have test parity with the previous transporters test file?
  3. Can you provide instructions for how downstream libraries will need to handle this change?
  4. Can you link any relevant PRs that explain how gaxios can provide this functionality? It seems like we're now just relying on gaxios for transporter and I couldn't immediately tell which commits where relevant here

*/
transporter?: Gaxios | Transporter;
gaxios?: Gaxios;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting a 404 and I'm not seeing it on the main branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Np, those aren't the same transporters referenced in this PR.

@@ -38,4 +39,31 @@ describe('AuthClient', () => {
assert.equal(authClient[camelCased], value);
}
});

it('should allow disabling of the default interceptor', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultimately, I'm a bit confused about this change: are we replacing functionality or removing it entirely? If replacing, it would be nice to see more test coverage (something at parity with confirming transporters functionality). If the latter, then I think maybe it would be best to add some type of warning for users attempting to use the Transporter property.

@d-goog
Copy link
Collaborator Author

d-goog commented Feb 6, 2025

In general, a few notes:

  1. The issues linked here don't make it immediately clear to me that we need to remove transporter. Can you help explain how you came to this solution?

That's fair, updated the description with particular incidences and background.

  1. It seems like this is just removing transporter. Since that is the case, can we add a warning to the transporter property, and confirm it with a test? If it really is refactoring, can we have test parity with the previous transporters test file?

Keeping transporter adds complexity to other future features, especially auth metrics, which would require more context from the auth instance itself.

A few tests currently covered the existing resulting behavior from Transporter. Examples:

I'll carry over a few more explicit tests.

  1. Can you provide instructions for how downstream libraries will need to handle this change?

Yep, I'm preparing a general migration guide for this auth release. I haven't seen our top libraries use custom transporters, so the migration shouldn't change much.

  1. Can you link any relevant PRs that explain how gaxios can provide this functionality? It seems like we're now just relying on gaxios for transporter and I couldn't immediately tell which commits where relevant here

As Transporter is mostly a wrapper around Gaxios, it currently provides all of the functionality from Transporter:

As for the auth-centric components, namely configure, that has moved to the AuthClient class.
As for processError, that was an artifact from the axios -> gaxios migration 7+ years ago:

@sofisl
Copy link
Contributor

sofisl commented Feb 6, 2025

Ok, sgtm. Thanks for the explanation. Would it be possible to keep this test file, and replace with the Gaxios transporter functionality?

@d-goog
Copy link
Collaborator Author

d-goog commented Feb 6, 2025

Ok, sgtm. Thanks for the explanation. Would it be possible to keep this test file, and replace with the Gaxios transporter functionality?

Yep, modernized and migrated the tests over into AuthClient's test file

@d-goog d-goog merged commit dbcc44b into main Feb 7, 2025
17 checks passed
@d-goog d-goog deleted the remove-transporter branch February 7, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants