Fix subpath deploy load failures (API 404, matrix=null hang)#281
Conversation
- Route library/shader API to storage.noahcohn.com in production builds (VITE_STORAGE_API_URL in build:xm-player + runtime PROD fallback) - Parse modules on main thread when libopenmpt is already initialized, avoiding slow/failing worker CDN WASM reload under strict COEP - Skip parser worker creation when main-thread lib is ready - Log detectRuntimeBase() in worklet diagnostics instead of raw BASE_URL Co-authored-by: Noah Cohn <noahc42@gmail.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PR adds a ChangesRuntime URL & Storage API Configuration
Main-thread libOpenMPT Parse Path
Sequence Diagram(s)sequenceDiagram
participant processModuleData
participant isLibReadyForParse
participant resolveParsedModule
participant parseOnMainThread
participant ParserWorker
processModuleData->>isLibReadyForParse: check lib._openmpt_module_create_from_memory2
isLibReadyForParse-->>processModuleData: ready = true / false
alt useWorkerParse = false (lib ready)
processModuleData->>resolveParsedModule: worker = null
resolveParsedModule->>parseOnMainThread: parseModuleWithLib(lib, data)
parseOnMainThread-->>resolveParsedModule: WorkerParseResponse
else useWorkerParse = true
processModuleData->>ParserWorker: create & start worker
processModuleData->>resolveParsedModule: worker = ParserWorker
ParserWorker-->>resolveParsedModule: WorkerParseResponse
end
resolveParsedModule-->>processModuleData: parsed module result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes console errors and stuck loading when the app runs at
https://test.1ink.us/xm-player/.Root causes
/api/songsand/api/shaders404 — production builds called relative/xm-player/api/*on the static host, but the library API lives onhttps://storage.noahcohn.com.matrix=nullafter module fetch — the parser worker re-downloaded libopenmpt WASM from CDN (15s+ timeout) even though the main thread already had WASM initialized. Under strict COEP (require-corpon the live server) this path is slow and unreliable.index.htmlstill references./assets/modplayer.1iss(corrupt CSS) andbase: /instead of/xm-player/. A freshnpm run build:xm-player:verifydeploy is required.Changes
utils/storageApi.ts: Production fallback tohttps://storage.noahcohn.comwhenVITE_STORAGE_API_URLis unset; dev still uses Vite/apiproxy.package.json:build:xm-playernow setsVITE_STORAGE_API_URL=https://storage.noahcohn.com.hooks/useLibOpenMPT.ts: Prefer main-thread parse when libopenmpt is ready; skip parser worker creation in the common case.audio-worklet/diagnostics.ts: LogdetectRuntimeBase()instead of rawimport.meta.env.BASE_URL.docs/DEPLOY.md: DocumentVITE_STORAGE_API_URL.Deploy steps
After deploy, verify:
Fetching→Parsing→Loadedwithin a few secondsstorage.noahcohn.com/api/songsindex.htmlreferences/xm-player/assets/index-*.css(notmodplayer.1iss)credentialless(.htaccessin dist overrides serverrequire-corp)Test plan
npm run typechecknpm run build:xm-player:verifySummary by CodeRabbit
Documentation
Chores