nbb

Gregory Bleiker 2025-05-12T08:59:36.622339Z

When trying to run an nrepl server with deno and cider, I get a sync nrepl request timed out Any ideas why?

βœ… 1
Gregory Bleiker 2025-05-12T09:05:26.510329Z

must be something to do with the imports: when using --unstable-node-globals it seems to work.

borkdude 2025-05-12T09:12:05.726939Z

Which version of node ?

borkdude 2025-05-12T09:12:25.428019Z

When upgrading to a still supported LTS version it should work

Gregory Bleiker 2025-05-12T09:12:26.711919Z

deno πŸ˜‰

borkdude 2025-05-12T09:12:35.680349Z

Ah

Gregory Bleiker 2025-05-12T09:12:57.998939Z

(it's me again πŸ™‚ )

πŸŽ‰ 1
borkdude 2025-05-12T09:13:04.733329Z

Then probably there’s something in the code of the nrepl server still relying on node

Gregory Bleiker 2025-05-12T09:14:06.815479Z

it's complaining that buffer is imported without node: prefix. However, I couldn't spot that code in the nbb repo

borkdude 2025-05-12T09:16:22.153579Z

how to reproduce this? I couldn't get the nrepl server working on deno yet, it's af it's blocking or buffering something which makes the output not appear

Gregory Bleiker 2025-05-12T09:17:27.495469Z

β€’ start nrepl with deno run -A jsr:@babashka/nbb nrepl-server

Gregory Bleiker 2025-05-12T09:17:42.023149Z

β€’ connect with cider (normal, like in readme)

borkdude 2025-05-12T09:18:13.338539Z

I have tried: lein repl :connect 49565 which is just stuck. works with node

borkdude 2025-05-12T09:19:34.983219Z

I've also seen behavior in bun not working well with networking code with the same code that works in node

Gregory Bleiker 2025-05-12T09:19:35.260829Z

then I ran an eval command in emacs, just a moment

Gregory Bleiker 2025-05-12T09:19:51.728869Z

the error showed up in the console

borkdude 2025-05-12T09:19:58.608559Z

In emacs I get "sync nREPL request timed out"

Gregory Bleiker 2025-05-12T09:20:08.677519Z

try with the unstable flag

borkdude 2025-05-12T09:20:32.718519Z

where do I put the flag?

Gregory Bleiker 2025-05-12T09:20:52.749899Z

deno -A --unstable-node-globals jsr:@babashka/nbb nrepl-server

borkdude 2025-05-12T09:21:32.354029Z

just works now!

borkdude 2025-05-12T09:21:39.052259Z

eval in emacs I mean

Gregory Bleiker 2025-05-12T09:21:46.273739Z

(cider-nrepl-sync-request:eval "(+ 1 2)")

borkdude 2025-05-12T09:21:59.254529Z

lein repl :connect 50167
doesn't work though

Gregory Bleiker 2025-05-12T09:22:00.432359Z

this is what gave me the buffer error

Gregory Bleiker 2025-05-12T09:22:24.184379Z

nREPL server started on port 42183 on host 127.0.0.1 - <nrepl://127.0.0.1:42183> error: Uncaught (in promise) ReferenceError: Buffer is not defined at a6 (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_nrepl_server.js:27:70) at https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_nrepl_server.js:28:62 at https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:986:363 at https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:986:376 at ch (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:95:304) at $http://APP.bh.$APP.g.fa (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:868:22) at Object.$APP.u (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:67:94) at Object.$APP.lh (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:97:74) at Oh.$APP.Oh.h (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_core.js:890:66) at a6 (https://jsr.io/@babashka/nbb/1.3.201/lib/nbb_nrepl_server.js:27:437) info: Buffer is not available in the global scope in Deno. hint: Import it explicitly with import { Buffer } from "node:buffer";, or run again with --unstable-node-globals flag to add this global.

Gregory Bleiker 2025-05-12T09:22:36.702609Z

is lein still a thing?

borkdude 2025-05-12T09:22:37.514639Z

borkdude 2025-05-12T09:22:47.055259Z

haha yes it is still a thing

borkdude 2025-05-12T09:23:17.984899Z

which version of deno do you have?

Gregory Bleiker 2025-05-12T09:23:23.129319Z

I'm also getting some Unhandled operation :version

Gregory Bleiker 2025-05-12T09:23:46.672039Z

but that might be normal for nbb, haven't cidered much into it upto now

borkdude 2025-05-12T09:24:10.584299Z

js/Deno.version => #js {:deno "2.3.1", :v8 "13.5.212.10-rusty", :typescript "5.8.3"}

Gregory Bleiker 2025-05-12T09:24:25.176849Z

deno 2.2.9 (stable, release, x86_64-unknown-linux-gnu) v8 13.5.212.10-rusty typescript 5.7.3

borkdude 2025-05-12T09:25:05.808129Z

Perhaps you can try to decompile the code a bit where Deno is pointing at

borkdude 2025-05-12T09:25:14.507469Z

could be that it's coming from a dependency

Gregory Bleiker 2025-05-12T09:25:24.077829Z

will do

Gregory Bleiker 2025-05-12T09:25:54.137799Z

did you ever get sourcemaps to work with nbb?

borkdude 2025-05-12T09:26:21.656509Z

ah yes, it's from the bencode implementation:

(defn utf8-bytes [s]
  (.-length (js/Buffer.from s)))

borkdude 2025-05-12T09:26:33.884989Z

I haven't tried

borkdude 2025-05-12T09:27:31.843729Z

I'll try with node:buffer

borkdude 2025-05-12T09:29:34.034779Z

same results as without it but perhaps for me the difference is node 2.3.1 instead of your 2.3.1

borkdude 2025-05-12T09:29:42.981139Z

happy to just commit this though. meanwhile you could try an upgrade

borkdude 2025-05-12T09:29:47.272729Z

of deno

borkdude 2025-05-12T09:30:41.132459Z

https://github.com/babashka/nbb/pull/386

borkdude 2025-05-12T09:33:00.346439Z

This PR doesn't work. Maybe js/Buffer and node:buffer are not the same?

borkdude 2025-05-12T09:33:37.907559Z

> var x = require("node:buffer")
undefined
> js/Buffer.from
Uncaught ReferenceError: js is not defined
> Buffer.from
[Function: from]
> x.from
undefined

borkdude 2025-05-12T09:38:30.005319Z

I'll get rid of Buffer altogether in this code

Gregory Bleiker 2025-05-12T09:38:46.435459Z

even better πŸ™‚

Gregory Bleiker 2025-05-12T09:40:36.366299Z

about deno update: I'm using arch linux. I'm a bit reluctant to upgrade packages outside of the package manager

borkdude 2025-05-12T09:40:57.712929Z

ok

borkdude 2025-05-12T09:43:23.140949Z

amazing, lein works now:

$ lein repl :connect 54355
Connecting to nREPL at 127.0.0.1:54355
Could not resolve symbol: nrepl.core/version
user=> (+ 1 2 3)
6

πŸš€ 1
borkdude 2025-05-12T09:47:59.204179Z

1.3.202 is now being published on CI, should be there once CI finishes

Gregory Bleiker 2025-05-12T09:48:27.390089Z

great, thanks!

borkdude 2025-05-12T09:52:12.336689Z

ok, it's there now

πŸ’ͺ 1
borkdude 2025-05-12T13:05:13.875909Z

$ time npx nbb@1.3.202 -e '(+ 1 2 3)'
6
npx nbb@1.3.202 -e '(+ 1 2 3)'   0,28s  user 0,08s system 78% cpu 0,463 total

$ time bun x nbb@1.3.202 -e '(+ 1 2 3)'
6
bun x nbb@1.3.202 -e '(+ 1 2 3)'   0,07s  user 0,02s system 98% cpu 0,091 total

$ time deno -A jsr:@babashka/nbb@1.3.202 -e '(+ 1 2 3)'
6
deno -A jsr:@babashka/nbb@1.3.202 -e '(+ 1 2 3)'   0,06s  user 0,02s system 113% cpu 0,067 total

πŸ‘€ 1
❀️ 1