#imported server stuff for loader blows up in client

1 messages · Page 1 of 1 (latest)

white raven
#

ok I have a DAO (database access object) that is to be server side and I want to call from the loader and I have gone through so many stages of wtf.

i'm importing this dao on the route where I need to load stuff, and I call its methods on the loader function, and that seems to be fine, but for some reason I get errors on the client referencing server stuff - latest being Buffer not being a thing and the stack going down to drizzle - but why is drizzlestuff also happening on the client side? I'm only using the dao in the loader and I can see that vite logs (on the server side) when the loader is invoked and retrieves the data

#

imported server stuff for loader blows up in client

lofty oyster
novel burrow
#

does your DAO lives in a module that has import side-effects? like just by importing it something else happens, an example is if you are instantiating things at the module scope instead of function scope

white raven
#

@lofty oyster , if I mark the DAO file as .server I can't import it in the route to use with the (serverside) loader

novel burrow
#

importing .server.ts files inside a route to use the imported code in the loader/action/middleware export works just fine, as long as your client code is not referencing anything from that server module

lofty oyster
white raven
#

I did try

#

let me tell you what happened

#

(I don't remember)

lofty oyster
#

If your client code does reference the server module, then it will give a helpful warning that can help you fix it

novel burrow
#

☝️

white raven
#

I'll get to it asap. by the way. anyone having problems with some sites / VPSs?

#

I'm having problems with my contabo and some other sites, a friend with a self hosted gitlab, and my dad with one of their client's site. like is there some backbone stuff down?

#

back on topic,

#

have some obvious one i'm fixing, wait

#

okay I hit a Server-only module referenced by client but you reinforcing me about it made me remember that I was calling it on an useEffect because I'm migrating this from a nextjs project where it was invoked as an rsc action and when I saw that yesterday I didn't process that part

#

thanks a lot

#

is there an idiom/convention for marking all files in a folder as server side?

#

without having to suffix them with .server.ts

#

❤️

white raven
#

hmm how do I define an API route where I won't return a react component

novel burrow
white raven
#

yeah sorry for asking before trying

#

doing that

#

miss the rsc actions typings

white raven
#

well uhhh

#

I fixed all client parts using server imports outside loader

#

but now I'm getting

#

Error: The render was aborted by the server without a reason.
at abort

#

nothing else

#

I used to at least see Server-only module referenced by client and I went one by one fixing them but now this is all

white raven
#

ok fixed by increasing streamTimeout on entry.server.tsx after npx react-router reveal

#

I think there ought to be better logging regarding that. I'm having throughput issues rn between my house's ISP and my contabo VPS, but "without a reason" is just terrible and confusing 🫠 I see it happens because it just calls abort() without an argument. I'm going to file a bug for that

#

I'd do a PR but giving it a string to that abort call just logs that string without the trace