Skip to content

Commit fbd0fe5

Browse files
Andrew Farriesroboquat
authored andcommitted
Remove client side eval of slow_database flag
The logic of checking the feature flag has moved to the backend (`proxy`) so we don't need this logic on the dashboard anymore.
1 parent 69187b2 commit fbd0fe5

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

components/dashboard/src/App.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Login } from "./Login";
1212
import { UserContext } from "./user-context";
1313
import { getSelectedTeamSlug, TeamsContext } from "./teams/teams-context";
1414
import { ThemeContext } from "./theme-context";
15-
import { getGitpodService, initGitPodService } from "./service/service";
15+
import { getGitpodService } from "./service/service";
1616
import { shouldSeeWhatsNew, WhatsNew } from "./whatsnew/WhatsNew";
1717
import gitpodIcon from "./icons/gitpod.svg";
1818
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
@@ -162,18 +162,14 @@ function App() {
162162
const { user, setUser, refreshUserBillingMode } = useContext(UserContext);
163163
const { teams, setTeams } = useContext(TeamsContext);
164164
const { setIsDark } = useContext(ThemeContext);
165-
const { usePublicApiTeamsService, useSlowDatabase } = useContext(FeatureFlagContext);
165+
const { usePublicApiTeamsService } = useContext(FeatureFlagContext);
166166

167167
const [loading, setLoading] = useState<boolean>(true);
168168
const [isWhatsNewShown, setWhatsNewShown] = useState(false);
169169
const [showUserIdePreference, setShowUserIdePreference] = useState(false);
170170
const [isSetupRequired, setSetupRequired] = useState(false);
171171
const history = useHistory();
172172

173-
useEffect(() => {
174-
initGitPodService(useSlowDatabase);
175-
}, [useSlowDatabase]);
176-
177173
useEffect(() => {
178174
(async () => {
179175
var user: User | undefined;

components/dashboard/src/contexts/FeatureFlagContext.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ const FeatureFlagContext = createContext<{
2121
showUseLastSuccessfulPrebuild: boolean;
2222
usePublicApiTeamsService: boolean;
2323
enablePersonalAccessTokens: boolean;
24-
useSlowDatabase: boolean;
2524
}>({
2625
showPersistentVolumeClaimUI: false,
2726
showUsageView: false,
2827
showUseLastSuccessfulPrebuild: false,
2928
usePublicApiTeamsService: false,
3029
enablePersonalAccessTokens: false,
31-
useSlowDatabase: false,
3230
});
3331

3432
const FeatureFlagContextProvider: React.FC = ({ children }) => {
@@ -42,7 +40,6 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
4240
const [showUseLastSuccessfulPrebuild, setShowUseLastSuccessfulPrebuild] = useState<boolean>(false);
4341
const [usePublicApiTeamsService, setUsePublicApiTeamsService] = useState<boolean>(false);
4442
const [enablePersonalAccessTokens, setPersonalAccessTokensEnabled] = useState<boolean>(false);
45-
const [useSlowDatabase, setUseSlowDatabase] = useState<boolean>(false);
4643

4744
useEffect(() => {
4845
if (!user) return;
@@ -53,7 +50,6 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
5350
showUseLastSuccessfulPrebuild: { defaultValue: false, setter: setShowUseLastSuccessfulPrebuild },
5451
publicApiExperimentalTeamsService: { defaultValue: false, setter: setUsePublicApiTeamsService },
5552
personalAccessTokensEnabled: { defaultValue: false, setter: setPersonalAccessTokensEnabled },
56-
slow_database: { defaultValue: false, setter: setUseSlowDatabase },
5753
};
5854

5955
for (const [flagName, config] of Object.entries(featureFlags)) {
@@ -98,7 +94,6 @@ const FeatureFlagContextProvider: React.FC = ({ children }) => {
9894
showUseLastSuccessfulPrebuild,
9995
usePublicApiTeamsService,
10096
enablePersonalAccessTokens,
101-
useSlowDatabase,
10297
}}
10398
>
10499
{children}

components/dashboard/src/service/service.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
1919

2020
export const gitpodHostUrl = new GitpodHostUrl(window.location.toString());
2121

22-
function createGitpodService<C extends GitpodClient, S extends GitpodServer>(useSlowDatabase: boolean = false) {
22+
function createGitpodService<C extends GitpodClient, S extends GitpodServer>() {
2323
if (window.top !== window.self && process.env.NODE_ENV === "production") {
2424
const connection = createWindowMessageConnection("gitpodServer", window.parent, "*");
2525
const factory = new JsonRpcProxyFactory<S>();
@@ -48,7 +48,6 @@ function createGitpodService<C extends GitpodClient, S extends GitpodServer>(use
4848
onListening: (socket) => {
4949
onReconnect = () => socket.reconnect();
5050
},
51-
subProtocol: useSlowDatabase ? "slow-database" : undefined,
5251
});
5352

5453
return new GitpodServiceImpl<C, S>(proxy, { onReconnect });
@@ -65,13 +64,4 @@ function getGitpodService(): GitpodService {
6564
return service;
6665
}
6766

68-
function initGitPodService(useSlowDatabase: boolean) {
69-
const w = window as any;
70-
const _gp = w._gp || (w._gp = {});
71-
if (window.location.search.includes("service=mock")) {
72-
_gp.gitpodService = require("./service-mock").gitpodServiceMock;
73-
}
74-
_gp.gitpodService = createGitpodService(useSlowDatabase);
75-
}
76-
77-
export { getGitpodService, initGitPodService };
67+
export { getGitpodService };

components/gitpod-protocol/src/messaging/browser/connection.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import ReconnectingWebSocket, { Event } from "reconnecting-websocket";
1616
export interface WebSocketOptions {
1717
onerror?: (event: Event) => void;
1818
onListening?: (socket: ReconnectingWebSocket) => void;
19-
subProtocol?: string;
2019
}
2120

2221
export class WebSocketConnectionProvider {
@@ -63,7 +62,7 @@ export class WebSocketConnectionProvider {
6362
*/
6463
listen(handler: ConnectionHandler, eventHandler: ConnectionEventHandler, options?: WebSocketOptions): WebSocket {
6564
const url = handler.path;
66-
const webSocket = this.createWebSocket(url, options);
65+
const webSocket = this.createWebSocket(url);
6766

6867
const logger = this.createLogger();
6968
if (options && options.onerror) {
@@ -87,8 +86,8 @@ export class WebSocketConnectionProvider {
8786
/**
8887
* Creates a web socket for the given url
8988
*/
90-
createWebSocket(url: string, options?: WebSocketOptions): WebSocket {
91-
return new ReconnectingWebSocket(url, options?.subProtocol, {
89+
createWebSocket(url: string): WebSocket {
90+
return new ReconnectingWebSocket(url, undefined, {
9291
maxReconnectionDelay: 10000,
9392
minReconnectionDelay: 1000,
9493
reconnectionDelayGrowFactor: 1.3,

0 commit comments

Comments
 (0)