Closed dev-guy closed 1 week ago
Not sure if this is related to your issue, but I've been dealing with a similar crash whenever the render function is called
{:node_js_worker_exit, {{:badarg, [{:erlang, :port_command, [#Port<0.69>, "[[\"server\",\"render\"]
Whenever my Svelte component is rendered, it'll trigger a callback function and call live.pushEvent
viewDidMount: function (info) {
live.pushEvent("svelte_viewDidMount", info)
},
However, I think because the Erlang port is in use during the render function, live.pushEvent will try using the same resource to communicate back to Phoenix and cause the crash. (no idea if this is true, just a theory). @woutdp, am I on the right track?
Anyways, I changed the callback function to become async and now there's no issues
viewDidMount: async function (info) {
// Wrap your asynchronous code in an async function
async function asyncOperations() {
// Your async operations here
await live.pushEvent("svelte_viewDidMount", info);
}
// Call the async function
asyncOperations()
.then(() => {
console.log("Async operations completed");
})
.catch((error) => {
console.error("Error in async operations:", error);
});
},
I filed this issue previously but I have since disabled SSR because I've had so many problems with it. Today even the 'counter' example wasn't working at all with SSR enabled (I'm using NodeJS 20.2.0) -- but it inexplicably started working again. The following scenario is consistent, however:
mix phx.server
). Hopefully you have Postgres installed already.Result: Error in browser. The following is sent to the console:
Other Items of Interest