Effect CommunityEC
Effect Community4w ago
32 replies
agr

Issues Integrating Effect with Tanstack Start App and HTTP 499 Errors

hi guys!

i've fallen in love with effect and I am desperate to use it wherever I can. The dream for me would be mapping it to an endpoint in my tanstack start app. But I'm doing something thick. I have written a toy app which works perfectly in a dedicated Effect server but when I try to integrate it into my tanstack start app none of my handlers complete and i get an HTTP 499 (client abort) response for every requests. At the moment I am doing:

// server.ts

export const RpcWebHandler = RpcServer.toHttpApp(CasesRpcs).pipe(
    Effect.map(HttpApp.toWebHandler),
    Effect.provide([CasesLive.pipe(Layer.provide(LoggerLayer)), RpcSerialization.layerNdjson])
).pipe(Effect.scoped);


// api.rpc.tsx
async function handler({request}: {request: Request}) {
    const _handler = await Effect.runPromise(RpcWebHandler);
    return await _handler(request);
}


export const Route = createFileRoute('/api/rpc')({
  server: {
    handlers: {
        GET: handler,
        POST: handler,
    },
  }
})


Do I need a managed runtime?! Any pointers greatly apprciated
Was this page helpful?