Skip to content

channels are not working with cloudflare workers #117

Description

@xydv

so i setup'd a basic application using workers,

channel

import { createChannel } from "better-sse";

const channel = createChannel();

export { channel as orderChannel };

/register to channel

import { createResponse } from "better-sse";
import { Hono } from "hono";
import { orderChannel } from "../channels/orderChannel";

const app = new Hono();

app.get("/register", (c) =>
  createResponse(c.req.raw, (session) => {
    orderChannel.register(session);
  }),
);

export default app;

/broadcast to channel

import { Hono } from "hono";
import { orderChannel } from "../channels/orderChannel";

const app = new Hono<{ Bindings: Env }>();

app.post(
  "/broadcast",
  async (c) => {
    orderChannel.broadcast("hi");
    return c.json([]);
  },
);

export default app;

upon subscribing to /register and sending events doesn't work, is it because of the serverless nature?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions