ex0ns
Explore posts from serversClosing resources and streaming response
Thanks for clarifying, though I don't think that it would work in my case, as this is pretty specific to the simpler reproducer I created to illustrate the problem I had, in my case the real scenario is a pool of connection to postgres (using postgres.js) that are closed before I could stream all the data to the frontend, and I could indeed call
postgres.end
manually at the end of all the method that use a postgres connection, but I don't really like this.
For now I think that I will go with the custom header to bypass the automatic cleanup + adding a cleanup function in c.var that some route would have to call whenever they are done to cleanup the resources (or maybe a custom ctx.set("stream",
to replace the default .stream
method from Hono and take care of closing the resources as well
Thanks for all the ideas34 replies
Closing resources and streaming response
This is the example for a single resource, but there might be more (in our case there is), I agree that I could somehow store this "cleanup" function in the context and make sure that all endpoint returning a stream call this cleanup function (either at the end of the streaming or in the onError callback), and continue closing it automatically for all other endpoints, but this is very error prone.
34 replies
Closing resources and streaming response
An idea I had was to detect the headers on
c.res.headers
to check if [ "transfer-encoding", "chunked" ]
was set or not and skip the resource cleanup in those case, but I really don't like this solution and this will in the long run still leak resources. (also the stream
helper does not seems to set the transfer-encoding
header, but the streamText
does)
Do you know how I could solve this issue ?34 replies
Hono SSE Stream Closing Unexpectedly After 10 Seconds
Honestly, I just node.js because I'm more familiar with it and was easier for me to work with Node.js, however due to some monorepo, bundling and typescript setup running our server locally on our laptop became a pain in the a** (tsx, ts-run, you name it always failed at some point), I decided to try bun to run TS natively and it worked amazingly so far.
16 replies
Does Hono Cloudflare Pages work with `@supabase/supabase-js`?
Side note (about workers): the last release of supabase-js/supabase-auth seems to have some issues when running inside the workers: https://github.com/supabase/supabase-js/issues/1001#issuecomment-2029478541
Using a previous version "just works".
This is not directly related to your question about Cloudflare Pages (I can't answer this part), but beware if you try to use cloudflare workers at the moment
19 replies