-
-
Notifications
You must be signed in to change notification settings - Fork 472
Description
Summary
The conversation centers around the use of a custom runtime when utilizing toWebHandler with the Effect Typescript library and the challenges of sharing a cache across requests in a Next.js environment. The user is transitioning from using ServerRuntime.runPromise to the new RPC system offered by Effect, and they are experiencing issues with state management, particularly maintaining a cache.
Key points and takeaways:
-
Layer vs. Effects: It’s important to distinguish between what should be initialized at bootstrap (as layers) and what should be request-scoped (as effects). Layers are memoized by their instance, so placing session-related data in layers could lead to issues since this data is expected to change per request.
-
RPC vs. HTTP: RPC (Remote Procedure Call) is intended to be protocol-agnostic, which contrasts with HTTP-specific APIs. In this case, the challenge is how to work within the protocol-agnostic constraints of the RPC system while needing HTTP request data.
-
Providing Request Data: There’s a discussion on how to provide request-specific data (like session data) to the RPC handlers. The suggestion is to abstract protocol access into a service that can be provided to the RPC implementation.
-
Technical Transition: The user is moving from tRPC to Effect RPC, resulting in architectural challenges. There's talk of revisiting the design to better suit the intended abstraction level of RPC, possibly reconsidering how state is shared across requests.
-
General Advice: The conversation touches on whether it’s appropriate to use RPC in such an HTTP-centric context, with a suggestion that using HTTP-specific APIs might better suit the user's needs if detailed control over HTTP semantics is required.
Overall, the discussion is technical, focusing on architecture and design patterns within the Effect Typescript library for managing runtime, state, and protocol concerns, particularly within a web context like Next.js.
Discord thread
https://discord.com/channels/795981131316985866/1354010412546527233