I have an issue where I can’t use Promesa in a :node-script target. It’s in an MCP server, and most clients work fine, except Claude Desktop which finds some code path where something crashes inside Promesa code. It’s a small script and I have removed Promesa from it so my project is fine. But I wonder what to do with reporting the problem. My repro isn’t exactly minimal, and I don’t understand at all why this happens. I don’t know if it’s a ClojureScript thing, Promesa, maybe even shadow. What would be my next step in trying to isolate and find more information about it? I get different crash logging when using ClojureScript 1.12.38 (nothing), than with 1.11.132 (a stack trace pointing me to Promesa).
well how does it fail? stack trace with async code can be tricky
I'd bet money its neither of those things and rather a problem in your code 😛
well actually I take that back. I never liked how promesa wraps promises and stuff
The error message seems to be about syntax of the generated JS code.. Here’s the trace:
2025-05-10T07:42:07.193Z [backseat-driver] [info] Initializing server...
2025-05-10T07:42:07.219Z [backseat-driver] [info] Server started and connected successfully
2025-05-10T07:42:07.220Z [backseat-driver] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
/Users/pez/Projects/calva-mcp-server/.shadow-cljs/builds/stdio-wrapper/dev/out/cljs-runtime/promesa.impl.promise.js:176
this[QUEUE].push({type:RESOLVE_TYPE_FLATTEN, resolve:resolve ?? defaultResolveMapHandler, reject:reject ?? defaultRejectHandler, complete:completeDeferredFn(deferred)});
^
SyntaxError: Unexpected token ?
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at global.SHADOW_IMPORT (/Users/pez/Projects/calva-mcp-server/dist/calva-mcp-server.js:56:15)
at /Users/pez/Projects/calva-mcp-server/dist/calva-mcp-server.js:1457:1
at Object.<anonymous> (/Users/pez/Projects/calva-mcp-server/dist/calva-mcp-server.js:1464:3)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
2025-05-10T07:42:07.956Z [backseat-driver] [info] Server transport closed
2025-05-10T07:42:07.956Z [backseat-driver] [info] Client transport closed
I think Claude Desktop is an Electron app. My script logs node version v10.15.3 . Which may not support the ?? syntax?what ?? syntax? cljs doesn't generate that for anything?
ah promesa is just plain JS in that case. yeah no clue what that syntax even is 😛
https://github.com/funcool/promesa/blob/master/src/promesa/impl/promise.js#L53
I have literally never seen ?? before. don't even know what that does
could be that this is related to how :node-script loads code in development. does this also happen for release builds?
does electron still not support ESM code?
Thanks. I knew I was asking in the right place. 😃
Happens in release builds too.
then I'd get rid of promesa. I never like it trying to be clever and wrap promises
OK, but then the right thing to do for this problem is to remove Promesa, since I can’t control what node environment the script is run from.
I can still use Promesa in my server 😃 It runs in VS Code, where we have a more modern Electron. I think Electron may support ESM these days, but I don’t know if VS Code is using a modern enough Electron yet.
?? is the native nullish coalescence operator which is typically used like aVar ?? "default-value" where if aVar is null or undefined, "default-value" is selected. If the value is falsey like "", 0, or false, that value will be used. Roughly syntax sugar for:
(aVar === null || aVar === undefined) ? "default-value" : avarwhat a sane language calls or 😉
I think the syntax was inspired by optionality thinking.
It's different than or.
"" || "other" // => "other"
"" ?? "other" // => ""I said sane language, so (or "" "other") 😉
Hello Folks,
I just got a new desktop Mac, and the vastly improved cores + memory made me wondering: what ways are there to tune my (CIDER) dev set up.
I normally do cider-jack-in-clj&cljs which runs my clojure and shadow-cljs stuff in my mono repo for my web app.
But would it speed things up (recompiles / hot reloads / startup times etc) if I for instance use different Xmx settings?
What is the route. I asked chatGPT, but the result was a bit hallucinating afaict.
the jvm defaults are pretty good. I doubt there many gains to be had. only reason to ever use xmx is to reduce memory use if memory limits are hit
you could experiment with gc settings, but I also doubt that'll make any noticeable difference
Alright thx