Skip to content

Commit

Permalink
Fix server errors (#7931)
Browse files Browse the repository at this point in the history
* Fix server errors
  • Loading branch information
jamakase authored Nov 12, 2021
1 parent 2744c82 commit fbf08b6
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 42 deletions.
1 change: 1 addition & 0 deletions airbyte-e2e-testing/cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"baseUrl": "http://localhost:3000",
"testFiles": [
"base.spec.js",
"onboarding.spec.js",
"connection.spec.js",
"destination.spec.js",
Expand Down
30 changes: 30 additions & 0 deletions airbyte-e2e-testing/cypress/integration/base.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe("Error handling view", () => {
it("Shows Version Mismatch page", () => {
cy.intercept("/api/v1/**", {
statusCode: 500,
body: {
error:
"Version mismatch between 0.0.1-ci and 0.0.2-ci.\nPlease upgrade or reset your Airbyte Database, see more at https://docs.airbyte.io/operator-guides/upgrading-airbyte",
},
});

cy.visit("/");

cy.get("div")
.contains("Version mismatch between 0.0.1-ci and 0.0.2-ci.")
.should("exist");
});

it("Shows Server Unavailable page", () => {
cy.intercept("/api/v1/**", {
statusCode: 502,
body: "Failed to fetch",
});

cy.visit("/");

cy.get("div")
.contains("Cannot reach server. The server may still be starting up.")
.should("exist");
});
});
38 changes: 19 additions & 19 deletions airbyte-webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ const services = {

const AppServices: React.FC = ({ children }) => (
<ServicesProvider inject={services}>
<ConfigServiceProvider
defaultConfig={defaultConfig}
providers={configProviders}
>
<ServiceOverrides>{children}</ServiceOverrides>
</ConfigServiceProvider>
<ServiceOverrides>{children}</ServiceOverrides>
</ServicesProvider>
);

Expand All @@ -101,19 +96,24 @@ const App: React.FC = () => {
<I18NProvider>
<StoreProvider>
<Suspense fallback={<LoadingPage />}>
<ApiErrorBoundary>
<FeatureService features={Features}>
<NotificationService>
<AppServices>
<AnalyticsInitializer>
<OnboardingServiceProvider>
<Routing />
</OnboardingServiceProvider>
</AnalyticsInitializer>
</AppServices>
</NotificationService>
</FeatureService>
</ApiErrorBoundary>
<ConfigServiceProvider
defaultConfig={defaultConfig}
providers={configProviders}
>
<ApiErrorBoundary>
<FeatureService features={Features}>
<NotificationService>
<AppServices>
<AnalyticsInitializer>
<OnboardingServiceProvider>
<Routing />
</OnboardingServiceProvider>
</AnalyticsInitializer>
</AppServices>
</NotificationService>
</FeatureService>
</ApiErrorBoundary>
</ConfigServiceProvider>
</Suspense>
</StoreProvider>
</I18NProvider>
Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/config/ConfigServiceProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const configContext = React.createContext<ConfigContext | null>(null);
export function useConfig<T extends Config>(): T {
const configService = useContext(configContext);

if (!configService) {
if (configService === null) {
throw new Error("useConfig must be used within a ConfigProvider");
}

Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/config/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const defaultConfig: Config = {
ui: uiConfig,
segment: { enabled: true, token: "" },
healthCheckInterval: 10000,
version: "",
version: "dev",
apiUrl: `${window.location.protocol}//${window.location.hostname}:8001/api/v1/`,
integrationUrl: "/docs",
oauthRedirectUrl: `${window.location.protocol}//${window.location.host}`,
Expand Down
33 changes: 18 additions & 15 deletions airbyte-webapp/src/packages/cloud/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Feature, FeatureItem, FeatureService } from "hooks/services/Feature";
import { AuthenticationProvider } from "packages/cloud/services/auth/AuthService";
import { AppServicesProvider } from "./services/AppServicesProvider";
import { IntercomProvider } from "./services/IntercomProvider";
import { ConfigProvider } from "./services/ConfigProvider";

const messages = Object.assign({}, en, cloudLocales);

Expand Down Expand Up @@ -55,21 +56,23 @@ const App: React.FC = () => {
<I18NProvider>
<StoreProvider>
<Suspense fallback={<LoadingPage />}>
<ApiErrorBoundary>
<NotificationServiceProvider>
<FeatureService features={Features}>
<AppServicesProvider>
<AuthenticationProvider>
<IntercomProvider>
<AnalyticsInitializer>
<Routing />
</AnalyticsInitializer>
</IntercomProvider>
</AuthenticationProvider>
</AppServicesProvider>
</FeatureService>
</NotificationServiceProvider>
</ApiErrorBoundary>
<ConfigProvider>
<ApiErrorBoundary>
<NotificationServiceProvider>
<FeatureService features={Features}>
<AppServicesProvider>
<AuthenticationProvider>
<IntercomProvider>
<AnalyticsInitializer>
<Routing />
</AnalyticsInitializer>
</IntercomProvider>
</AuthenticationProvider>
</AppServicesProvider>
</FeatureService>
</NotificationServiceProvider>
</ApiErrorBoundary>
</ConfigProvider>
</Suspense>
</StoreProvider>
</I18NProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
useInjectServices,
} from "core/servicesProvider";
import { useApiServices } from "core/defaultServices";
import { ConfigProvider } from "./ConfigProvider";
import { FirebaseSdkProvider } from "./FirebaseSdkProvider";

import { useWorkspaceService } from "./workspaces/WorkspacesService";
Expand Down Expand Up @@ -50,11 +49,9 @@ const AppServicesProvider: React.FC = ({ children }) => {
);
return (
<ServicesProvider inject={services}>
<ConfigProvider>
<FirebaseSdkProvider>
<ServiceOverrides>{children}</ServiceOverrides>
</FirebaseSdkProvider>
</ConfigProvider>
<FirebaseSdkProvider>
<ServiceOverrides>{children}</ServiceOverrides>
</FirebaseSdkProvider>
</ServicesProvider>
);
};
Expand Down

0 comments on commit fbf08b6

Please sign in to comment.