Skip to content

Commit 4752c41

Browse files
authored
fix: subdomain config loads from root (#677)
* chore: config-context isLoading var * fix: subdomains get config from root * chore: add header back to subdomain only config page requests * fix: use loading indicator * chore: minor code cleanup * chore: use query param for origin isolation acceptance * chore: update test wait for sw fixture * test: debugging fix for getting github CI to pass * chore: increase playwright timeout in CI * chore: increase playwright timeout in CI * chore: more e2e fixes for CI * chore: remove navigateAndGetSwResponse * chore: attempt to use macos runner * chore: invalidate playwright cache * chore: enable playwright debug * Revert "chore: attempt to use macos runner" This reverts commit bb8fcad. * chore: ensure playwright debug without headed * chore: still trying to fix CI * chore: fix subdomain redirect test * chore: use correct playwright results path * chore: validate kubo gateway returns key * fix: set ipfs-sw header on all responses from sw * chore: ugh * chore: revert github ci changes. add playwright artifact upload to ff * chore: skip libp2p-key test for now * chore: more logging in playwright * chore: more logging for ipns record loading * chore: debugging libp2p-key test * chore: i'm done messing with github CI borked-edness
1 parent b3de5a6 commit 4752c41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+324
-267
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ jobs:
8282
with:
8383
flags: chrome
8484
files: .coverage/*,packages/*/.coverage/*
85+
- name: Upload Playwright artifacts
86+
if: always()
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: playwright-debug
90+
path: test-results
8591

8692
test-chrome-webworker:
8793
needs: build

package-lock.json

Lines changed: 98 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"license": "MIT",
99
"scripts": {
1010
"reset": "npm run clean -- **/node_modules **/package-lock.json",
11-
"clean": "aegir clean dist dist-tsc test-e2e/fixtures/data/gateway-conformance-fixtures test-e2e/fixtures/data/test-repo",
11+
"clean": "aegir clean dist dist-tsc test-e2e/fixtures/data/gateway-conformance-fixtures",
1212
"dep-check": "aegir dep-check",
1313
"lint": "aegir lint",
1414
"lint:fix": "aegir lint --fix",

playwright.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ export default defineConfig({
44
testDir: './test-e2e',
55
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
66
/* Run tests in files in parallel */
7-
fullyParallel: true,
7+
fullyParallel: process.env.CI == null,
88
/* Fail the build on CI if you accidentally left test.only in the source code. */
99
forbidOnly: Boolean(process.env.CI),
1010
/* Retry on CI only */
1111
retries: (process.env.CI != null) ? 2 : 0,
12+
timeout: process.env.CI != null ? 120 * 1000 : undefined,
1213

1314
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
1415
// reporter: 'html', // Uncomment to generate HTML report
@@ -86,7 +87,7 @@ export default defineConfig({
8687
command: process.env.SHOULD_BUILD !== 'false' ? 'npm run build && npx http-server --silent -p 3000 dist' : 'npx http-server --silent -p 3000 dist',
8788
port: 3000,
8889
timeout: 60 * 1000,
89-
reuseExistingServer: !process.env.CI,
90+
reuseExistingServer: false,
9091
stdout: process.env.CI ? undefined : 'pipe',
9192
stderr: process.env.CI ? undefined : 'pipe'
9293
}

serve.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,16 @@ async function loadFixtures (): Promise<{
3131
await controller.start()
3232

3333
await loadCarFixtures()
34-
await loadIpnsRecords(controller, log)
35-
34+
// eslint-disable-next-line no-console
35+
console.log('loading ipns records')
36+
try {
37+
await loadIpnsRecords(controller, log)
38+
} catch (error) {
39+
// eslint-disable-next-line no-console
40+
console.error('error loading ipns records', error)
41+
}
42+
// eslint-disable-next-line no-console
43+
console.log('loaded ipns records')
3644
return {
3745
controller
3846
}

src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Suspense, useEffect } from 'react'
2+
import LoadingIndicator from './components/loading-indicator.jsx'
23
import { RouteContext } from './context/router-context.jsx'
34
import { checkSubdomainSupport } from './lib/check-subdomain-support.js'
45
import './app.css'
@@ -11,8 +12,7 @@ function App (): React.ReactElement {
1112
}, [])
1213

1314
return (
14-
// TODO: replace with <LoadingPage />
15-
<Suspense fallback={<div>Loading...</div>}>
15+
<Suspense fallback={<LoadingIndicator />}>
1616
{currentRoute?.component != null && <currentRoute.component />}
1717
</Suspense>
1818
)
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react'
2+
import './loading-indicator.css'
3+
4+
export default function LoadingIndicator (): React.ReactElement {
5+
return (
6+
<div className="loading-animation"></div>
7+
)
8+
}

src/context/config-context.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type ConfigKey = keyof ConfigDb
77
export interface ConfigContextType extends ConfigDb {
88
setConfig(key: ConfigKey, value: any): void
99
resetConfig(logger?: ComponentLogger): Promise<void>
10+
isLoading: boolean
1011
}
1112

1213
export const ConfigContext = createContext<ConfigContextType>({
@@ -21,10 +22,12 @@ export const ConfigContext = createContext<ConfigContextType>({
2122
enableGatewayProviders: defaultEnableGatewayProviders,
2223
enableRecursiveGateways: defaultEnableRecursiveGateways,
2324
debug: defaultDebug(),
24-
_supportsSubdomains: defaultSupportsSubdomains
25+
_supportsSubdomains: defaultSupportsSubdomains,
26+
isLoading: true
2527
})
2628

2729
export const ConfigProvider: React.FC<{ children: ReactElement[] | ReactElement, expanded?: boolean }> = ({ children }) => {
30+
const [isLoading, setIsLoading] = useState(true)
2831
const [gateways, setGateways] = useState<string[]>(defaultGateways)
2932
const [routers, setRouters] = useState<string[]>(defaultRouters)
3033
const [dnsJsonResolvers, setDnsJsonResolvers] = useState<Record<string, string>>(defaultDnsJsonResolvers)
@@ -54,6 +57,8 @@ export const ConfigProvider: React.FC<{ children: ReactElement[] | ReactElement,
5457
useEffect(() => {
5558
void loadConfig().catch((err) => {
5659
log.error('Error loading config', err)
60+
}).finally(() => {
61+
setIsLoading(false)
5762
})
5863
}, [])
5964

@@ -100,8 +105,23 @@ export const ConfigProvider: React.FC<{ children: ReactElement[] | ReactElement,
100105
await loadConfig()
101106
}
102107

108+
const finalConfigContext: ConfigContextType = {
109+
setConfig: setConfigLocal,
110+
resetConfig: resetConfigLocal,
111+
gateways,
112+
routers,
113+
dnsJsonResolvers,
114+
enableWss,
115+
enableWebTransport,
116+
enableGatewayProviders,
117+
enableRecursiveGateways,
118+
debug,
119+
_supportsSubdomains,
120+
isLoading
121+
}
122+
103123
return (
104-
<ConfigContext.Provider value={{ setConfig: setConfigLocal, resetConfig: resetConfigLocal, gateways, routers, dnsJsonResolvers, enableWss, enableWebTransport, enableGatewayProviders, enableRecursiveGateways, debug, _supportsSubdomains }}>
124+
<ConfigContext.Provider value={finalConfigContext}>
105125
{children}
106126
</ConfigContext.Provider>
107127
)

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ if ('serviceWorker' in navigator) {
2525
const routes: Route[] = [
2626
{ shouldRender: renderChecks.shouldRenderFirstHitPage, component: LazyFirstHitPage },
2727
{ default: true, component: ErrorPage ?? LazyHelperUi },
28+
{ shouldRender: async () => renderChecks.shouldRenderConfigPage(), component: LazyConfig },
2829
{ shouldRender: async () => renderChecks.shouldRenderNoServiceWorkerError(), component: LazyServiceWorkerErrorPage },
2930
{ shouldRender: renderChecks.shouldRenderSubdomainWarningPage, component: LazySubdomainWarningPage },
3031
{ shouldRender: async () => renderChecks.shouldRenderRedirectsInterstitial(), component: LazyInterstitial },
31-
{ path: '#/ipfs-sw-config', shouldRender: async () => renderChecks.shouldRenderConfigPage(), component: LazyConfig },
3232
{
3333
shouldRender: async () => renderChecks.shouldRenderRedirectPage(),
3434
component: LazyRedirectPage

0 commit comments

Comments
 (0)