News for hackers. Stuff that matters.
Re:Lightpanda: The headless browser designed for AI and auto... by frankgrecojr on Friday January 24, 2025 @03:35PM (#42816664)
The hello world example does not work. In fact, no website I've tried works. It's usually always panics. For the example in the readme, the errors are:

```

./lightpanda-aarch64-macos --host 127.0.0.1 --port 9222

info(websocket): starting blocking worker to listen on 127.0.0.1:9222

info(server): accepting new conn...

info(server): client connected

info(browser): GET https://wikipedia.com/ 200

info(browser): fetch https://wikipedia.com/portal/wikipedia.org/assets/js/index-2...: http.Status.ok

info(browser): eval script portal/wikipedia.org/assets/js/index-24c3e2ca18.js: ReferenceError: location is not defined

info(browser): fetch https://wikipedia.com/portal/wikipedia.org/assets/js/gt-ie9-...: http.Status.ok

error(events): event handler error: error.JSExecCallback

info(events): event handler error try catch: TypeError: Cannot read properties of undefined (reading 'length')

info(server): close cmd, closing conn...

info(server): accepting new conn...

thread 5274880 panic: attempt to use null value

zsh: abort ./lightpanda-aarch64-macos --host 127.0.0.1 --port 9222

```

Re:Lightpanda: The headless browser designed for AI and auto... by lbotos on Friday January 24, 2025 @08:04PM (#42818479)
Not OP -- do you have some kind of proxy or firewall?

Looks like you couldn't download https://wikipedia.com/portal/wikipedia.org/assets/js/gt-ie9-... for some reason.

In my contributions to joplin s3 backend "Cannot read properties of undefined (reading 'length')" was usually when you were trying to access an object that wasn't instantiated. (Can't figure out length of <undefined>)

So for some reason it seems you can't execute JS?

Re:Lightpanda: The headless browser designed for AI and auto... by zelcon on Friday January 24, 2025 @10:40PM (#42819267)
That's Zig for you. A ``modern'' systems programming language with no borrow checker or even RAII.
Re:Lightpanda: The headless browser designed for AI and auto... by hansvm on Saturday January 25, 2025 @12:49AM (#42819795)
Those statements are mostly true and also worth talking about, but they're not pertinent to that error (remotely provided JS not behaving correctly), or the eventual crash (which you'd cause exactly the same way for the same reason in Rust with a .unwrap() call).
Re:Lightpanda: The headless browser designed for AI and auto... by jbggs on Saturday January 25, 2025 @01:48AM (#42819951)
you shouldn't be unwrapping, error cases should be properly handled. users shouldn't see null dereference errors without any context, even in cli tools...
Re:Lightpanda: The headless browser designed for AI and auto... by hansvm on Saturday January 25, 2025 @05:19PM (#42825474)
That too, as a general coding pattern. I was commenting on the criticism of Zig as a sub-par system's language though, contrasting with a language most people with that opinion seem to like.
Re:Lightpanda: The headless browser designed for AI and auto... by IshKebab on Saturday January 25, 2025 @05:14AM (#42820734)
Not exactly the same. `.unwrap()` will never lead to UB, but this can in Zig in release mode.

Also `unwrap()`s are a lot more obvious than just a ?. Dangerous operations should require more ceremony than safe ones. Surprising to see Zig make such a mistake.

Re:Lightpanda: The headless browser designed for AI and auto... by hansvm on Saturday January 25, 2025 @05:29PM (#42825560)
> UB vs "safe" panic

Yes, it's not exactly the same if you compile in ReleaseFast instead of ReleaseSafe. Both are bad though, and I'd tend to blame the coding pattern for the observed behavior rather than quibble about which unacceptable scenario is worse.

I see people adopting forced null unwrapping for dumb reasons all the time. For the remaining reasons, do you have a sense of what the language deficiencies are which make that feature helpful? I see it for somewhat sane reasons when crossing language boundaries. Does anything else stand out?

> ceremony

Yes. Thankfully ".?" is greppable, but I wouldn't mind more ceremony there, and less for `try` coding patterns.

Re:Lightpanda: The headless browser designed for AI and auto... by igorguerrero on Saturday January 25, 2025 @01:33AM (#42819912)
You could build the same thing in Rust and have the same exact issue.
Re:Lightpanda: The headless browser designed for AI and auto... by steeve on Saturday January 25, 2025 @06:12AM (#42820953)
That has absolutely nothing to do with RAII or safety…
Re:Lightpanda: The headless browser designed for AI and auto... by audunw on Saturday January 25, 2025 @07:25AM (#42821221)
If that kind of stuff is always preferable, the nobody would use C over C++, yet to this day many projects still do. Borrow checking isn’t free. It’s a trade-off.

I mean, you could say Rust isn’t a modern language because it doesn’t use garbage collection. But it’s a nonsensical statement. Different languages serve different purposes.

Besides, Zig is focusing a lot more on heavily integrating testing, debug modes, fuzzing, etc. in the compiler itself, which when put together will catch almost all of the bugs a borrow checker catches, but also a whole ton of other classes of bugs that Rust doesn’t have compile time checks for.

I would probably still pick Rust in cases where it’s absolutely critical to avoid bugs that compromise security.

But this project isn’t that kind of project. I’d imagine that the super fast compile times and rapid iteration that Zig provides is much more useful here.

Re:Lightpanda: The headless browser designed for AI and auto... by krichprollsch on Saturday January 25, 2025 @04:49AM (#42820633)
Lightpanda co-author here.

Thanks for opening the issue in the repo. To be clear here, the crash seems relative with a socket disconnection issue in our CDP server.

> info(events): event handler error try catch: TypeError: Cannot read properties of undefined (reading 'length')

This message relates to the execution of gt-ie9-ce3fe8e88d.js. It's not the origin of the crash.

I have to dig in, but it could be due to a missing web API.