Fix loading wasm for ydocs server (#8952)

#8893 introduced a fatal regression for old IDE + new IDE also does not work on every system.

The fix:
1. Don't assume that WASM needed by ydocs server is bundled
2. Don't assume we know its exact name.
This commit is contained in:
Adam Obuchowicz 2024-02-02 17:01:58 +01:00 committed by GitHub
parent 4ea2ad5281
commit 8eeef71c26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,14 +102,21 @@ export class Server {
reject(err)
}
// Prepare the YDoc server access point for the new Vue-based GUI.
if (httpServer) {
// TODO[ao]: This is very ugly quickfix to make our rust-ffi WASM
// working both in browser and in ydocs server. Doing it properly
// is tracked in https://github.com/enso-org/enso/issues/8931
const assets = path.join(paths.ASSETS_PATH, 'assets')
const bundledFiles = fs.existsSync(assets) ? fs.readdirSync(assets) : []
const rustFFIWasm = bundledFiles.find(name =>
/rust_ffi_bg-.*\.wasm/.test(name)
)
if (httpServer && rustFFIWasm != null) {
await ydocServer.createGatewayServer(
httpServer,
// TODO[ao]: This is very ugly quickfix to make our rust-ffi WASM
// working both in browser and in ydocs server. Doing it properly
// is tracked in https://github.com/enso-org/enso/issues/8931
path.join(paths.ASSETS_PATH, 'assets', 'rust_ffi_bg-c353f976.wasm')
path.join(assets, rustFFIWasm)
)
} else {
logger.warn('YDocs server is not run, new GUI may not work properly!')
}
logger.log(`Server started on port ${this.config.port}.`)
logger.log(