4 ms·
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: ``` ./
by frankgrecojr 2y ago
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/ https://wikipedia.com/ 200
info(browser): fetch https://wikipedia.com/portal/wikipedia.org/assets/js/index-24c3e2ca18.js 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-ce3fe8e88d.js 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
```
- lbotos 2y agoNot 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-ce3fe8e88d.js 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?
- zelcon 2y agoThat's Zig for you. A ``modern'' systems programming language with no borrow checker or even RAII.
- hansvm 2y agoThose 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).
- jbggs 2y agoyou shouldn't be unwrapping, error cases should be properly handled. users shouldn't see null dereference errors without any context, even in cli tools...
- hansvm 2y agoThat 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.
- IshKebab 2y agoNot 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.
- hansvm 2y ago> 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.
- igorguerrero 2y agoYou could build the same thing in Rust and have the same exact issue.
- steeve 2y agoThat has absolutely nothing to do with RAII or safety…
- audunw 2y agoIf 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.
- krichprollsch 2y agoLightpanda 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.