vlmlee
vlmlee3y ago

Reactive!

cool 😁 I was quite interested in the "reactive" branding you guys had. Is that based on the push/pull sub/pub model of "reactive" programming?
28 Replies
ballingt
ballingt3y ago
The pub/sub part is there but that feels like an implementation detail, the core thing is writing imperative code (query functions) that act like declarative/reactive data views via some cool implementation details (tracking database reads, deterministic execution etc.) Convex knows when to push new data to clients
vlmlee
vlmleeOP3y ago
Hm ok, I will need to do the tutorial to see how it differs from trpc
ballingt
ballingt3y ago
Please let us know if you have questions after! Hopefully the first page of the tutorial makes this clear. tRPC is really sweet, some ways Convex goes beyond tRPC are - consistent views of data: all endpoints update simultaneously, in the same React render - streaming by default: every query updates only when it has changed
vlmlee
vlmleeOP3y ago
yes, tRPC, or RPCs in general, aren't designed for pub/sub but it's sooo good at what it does, which is being better than REST lol Hmmm, one issue I just found is that the dev server doesn't complain if the port is already in use 👀
ballingt
ballingt3y ago
the frontend or backend dev server? for me backend does notice, and the frontend dev server chooses a different port
vlmlee
vlmleeOP3y ago
the frontend dev server didn't choose a different port for me, so I got confused when I hit another create-<blank>-app I had running
ballingt
ballingt3y ago
ah ok I can repro this with nc -l 3000 in one terminal and npm run dev in another. I think this is a limitation of how Vite detects ports in use.
vlmlee
vlmleeOP3y ago
I see 👀
vlmlee
vlmleeOP3y ago
yeah
ballingt
ballingt3y ago
What was the other project? perhaps it was bound to 0.0.0.0:3000 instead of localhost:3000 (but regardless, probably not going to be able to fix this soon) but thank you, this is just the kind of problem we'd love to hear about
vlmlee
vlmleeOP3y ago
It was the create-t3-app running the next.js dev server
vlmlee
vlmleeOP3y ago
and yes, you were right, it was bound to 0.0.0.0
No description
ballingt
ballingt3y ago
sounds like something for Vite and Next.js to work out between themselves 😆 although maybe Vite could check both? filed @vlmlee https://github.com/vitejs/vite/issues/10638
vlmlee
vlmleeOP3y ago
The beauty of OSS
ballingt
ballingt3y ago
They like the idea, now to wait for a flight this weekend to write the PR
vlmlee
vlmleeOP3y ago
I dug into the code but it's not apparent how they check for an occupied port other than onError here: https://github.com/vitejs/vite/blob/ee7c28a46a6563d54b828af42570c55f16b15d2c/packages/vite/src/node/http.ts#L163
GitHub
vite/http.ts at ee7c28a46a6563d54b828af42570c55f16b15d2c · vitejs/v...
Next generation frontend tooling. It's fast! Contribute to vitejs/vite development by creating an account on GitHub.
vlmlee
vlmleeOP3y ago
probably just need to add logic for checking the host variable, for transforming 0.0.0.0 and 127.0.0.1 into one another
vlmlee
vlmleeOP3y ago
Don't really know if this applies for this use case
No description
ballingt
ballingt3y ago
yeah maybe we need to actually try to connect to check, hopefully there's some syscall that tells us
vlmlee
vlmleeOP3y ago
hm yeah, currently the server starts first and waits for an error a precheck though might not be the right answer since it makes the error checking event listener redundant there might be a better solution within node.http with a setting or something
ballingt
ballingt3y ago
we could add a health check after setting up the server
vlmlee
vlmleeOP3y ago
not sure what the right answer is... It doesn't seem like the nextjs dev server cares that vite is running on localhost:3000 anyways by running vite dev server first then nextjs you can get to the convex app through 0.0.0.0:3000 however when running both apps so it's definitely a bug In the context of servers, 0.0.0.0 means "all IPv4 addresses on the local machine." If a host has two IP addresses, and a server running on the host listens to 0.0.0.0, it will be reachable by both of those IPs seems kinda deliberate on next.js's part or maybe they didn't really know the difference, like how I don't really understand the difference doesn't look like there's a configuration for this problem
vlmlee
vlmleeOP3y ago
Super User
What's the difference between 127.0.0.1 and 0.0.0.0?
I understand that 127.0.0.1 points to localhost, and so does 0.0.0.0 (correct me if I'm wrong). So, what's the difference between 127.0.0.1 and 0.0.0.0?
ballingt
ballingt3y ago
yeah I think it's reasonable that they use 0.0.0.0, I bet that's what using --host with vite does prefer Vite's default for security though
vlmlee
vlmleeOP3y ago
GitHub
vite/utils.ts at ee7c28a46a6563d54b828af42570c55f16b15d2c · vitejs/...
Next generation frontend tooling. It's fast! Contribute to vitejs/vite development by creating an account on GitHub.
vlmlee
vlmleeOP3y ago
Forgot to mention this resolver actually, I'm coming around to this as a good solution
vlmlee
vlmleeOP3y ago
@ballingt looks like the person who replied provided a fix 👀 https://github.com/vitejs/vite/pull/10651/commits/f69a78f6382a09309730a97400bf512d4ea04f40
GitHub
fix: already in use port #10638 by Scttpr · Pull Request #10651 · v...
Description This PR is solving issue 10638. After a short investigation, recent NodeJS versions will not detect running processes on 0.0.0.0:&lt;desired_port&gt; if the provided host is lo...

Did you find this page helpful?