Skip to content

Commit cec2ca4

Browse files
committed
[ fix ] Include --setup to ALS WASM
1 parent 07aaf1a commit cec2ca4

File tree

4 files changed

+68
-14
lines changed

4 files changed

+68
-14
lines changed

lib/js/src/Connection/Connection.bs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/src/Connection/Protocol/Connection__Protocol__LSP__Binding.bs.js

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

src/Connection/Connection.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ module Module: Module = {
435435
| Connection__Download.DownloadOrderAbstract.DevWASMALS =>
436436
switch await Connection__Download.downloadFromURL(
437437
globalStorageUri,
438-
"https://unpkg.com/[email protected].1/als/2.8.0/als.wasm",
438+
"https://unpkg.com/[email protected].3-als.2.8.0/als/2.8.0/als.wasm",
439439
"dev-wasm-als",
440440
"Agda Language Server (WASM)",
441441
) {

src/Connection/Protocol/Connection__Protocol__LSP__Binding.res

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,39 @@ module ServerOptions = {
201201

202202
let makeWithWASM: WASMLoader.t => t = %raw(`
203203
(wasmSetup) => {
204-
const createTransport = () =>
205-
wasmSetup.factory.createServer(
206-
wasmSetup.memfsAgdaDataDir,
207-
{},
208-
{ runSetupFirst: false },
209-
);
204+
const createTransport = () => {
205+
const attemptWithSetup = () => wasmSetup.factory.createServer(
206+
wasmSetup.memfsAgdaDataDir,
207+
{},
208+
{
209+
runSetupFirst: true,
210+
setupCallback(exitCode, stderr) {
211+
if (exitCode === 0) {
212+
console.log('[agda-mode] ALS WASM setup completed successfully.');
213+
} else {
214+
console.warn('[agda-mode] ALS WASM setup exited with code ' + exitCode + ': ' + stderr);
215+
}
216+
},
217+
},
218+
);
219+
220+
const attemptWithoutSetup = () => wasmSetup.factory.createServer(
221+
wasmSetup.memfsAgdaDataDir,
222+
{},
223+
{ runSetupFirst: false },
224+
);
225+
226+
return Promise.resolve()
227+
.then(attemptWithSetup)
228+
.catch((error) => {
229+
const message = error && (error.message || String(error));
230+
if (typeof message === 'string' && message.includes('--setup')) {
231+
console.warn('[agda-mode] ALS WASM binary does not support --setup; retrying without setup.');
232+
return attemptWithoutSetup();
233+
}
234+
throw error;
235+
});
236+
};
210237
211238
Object.defineProperty(createTransport, "__agdaModeWasm", {
212239
value: true,

0 commit comments

Comments
 (0)