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

🪟 🐛 Poll backend for Free Connector Program enrollment success #22289

Merged
merged 4 commits into from
Feb 8, 2023

Conversation

ambirdsall
Copy link
Contributor

@ambirdsall ambirdsall commented Feb 2, 2023

What

Closes #22302.

  • when a user navigates to a page whose render invokes useFreeConnectorProgram() with the fcpEnrollmentSuccess query param, starts polling the FCP program info endpoint
  • if polled return value ever says hasPaymentAccountSaved is true, stop polling, hide enrollment banners, and show success UI
  • if 10s elapses with no enrollment, show an error popup instead

How

Adds a general-purpose pollUntil function, then uses that to poll the endpoint.

Recommended reading order

  1. useFreeConnectorProgram.ts
  2. pollUntil.ts or pollUntil.test.ts, depending on how you feel about rxjs, followed by the other

@octavia-squidington-iii octavia-squidington-iii added the area/frontend Related to the Airbyte webapp label Feb 2, 2023
@ambirdsall ambirdsall force-pushed the alex/poll-backend-for-FCP-enrollment-success branch from 8320b37 to 14215ce Compare February 2, 2023 09:53
@ambirdsall ambirdsall marked this pull request as ready for review February 2, 2023 09:57
Copy link
Contributor

@josephkmh josephkmh left a comment

Choose a reason for hiding this comment

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

Nice utility! I imagine this could be useful for short polling in other instances 👍

airbyte-webapp/src/core/request/pollUntil.ts Outdated Show resolved Hide resolved
airbyte-webapp/src/core/request/pollUntil.ts Outdated Show resolved Hide resolved
id: "fcp/enrolled",
text: formatMessage({ id: "freeConnectorProgram.enroll.success" }),
type: ToastType.SUCCESS,
pollUntil(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have pretty similar code in

useEffectOnce(() => {
// If we are coming back from a successfull stripe checkout ...
if (searchParams.has(STRIPE_SUCCESS_QUERY)) {
// Remove the stripe parameter from the URL
setSearchParams({}, { replace: true });
// If the workspace doesn't have a recent increase in credits our server has not yet
// received the Stripe callback or updated the workspace information. We're going to
// switch into a loading mode and relaod the workspace every 3s from now on until
// the workspace has received the credit update (see useEffect below)
if (!hasRecentCreditIncrease(cloudWorkspace)) {
setIsWaitingForCredits(true);
retryIntervalId.current = window.setInterval(() => {
invalidateCloudWorkspace();
}, 3000);
}
}
return () => clearInterval(retryIntervalId.current);
});
Maybe it's worth switching that also over to use the pollUntil utility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great callout. We also do a bunch of manual interval wrangling for the health check endpoint, too; it would be good to consolidate our polling approaches.

That said, it would be nice to get this change merged to close an annoying edge case first, so I'm inclined to ship those updates as a follow up PR.

@ambirdsall ambirdsall force-pushed the alex/poll-backend-for-FCP-enrollment-success branch 2 times, most recently from 5529451 to 694dce1 Compare February 6, 2023 21:27
@ambirdsall ambirdsall force-pushed the alex/poll-backend-for-FCP-enrollment-success branch from 694dce1 to db88c72 Compare February 7, 2023 00:32
@ambirdsall ambirdsall merged commit 8e57542 into master Feb 8, 2023
@ambirdsall ambirdsall deleted the alex/poll-backend-for-FCP-enrollment-success branch February 8, 2023 23:38
danidelvalle pushed a commit to danidelvalle/airbyte that referenced this pull request Feb 9, 2023
…tehq#22289)

* Add pollUntil utility for polling Promises

* poll backend for confirmed enrollment before showing success toast

* Put interval and maxTimeout inside options arg

* Give units w/ polling options: intervalMs and maxTimeoutMs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate free connector program enrollment with backend before showing success/error UI notifications
5 participants