You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using NodeJs 21.6.2 and deployed on Vercel. Using chrome Version 124.0.6367.61 (Offizieller Build)
Reproduction
* import { createEventStream, sendEventStream } from "h3";
*
* eventHandler((event) => {
* const eventStream = createEventStream(event);
*
* // Send a message every second
* const interval = setInterval(async () => {
* await eventStream.push("Hello world");
* }, 1000);
*
* // cleanup the interval and close the stream when the connection is terminated
* eventStream.onClosed(async () => {
* console.log("closing SSE...");
* clearInterval(interval);
* await eventStream.close();
* });
*
* return eventStream.send();
* });
* ```
- This is the default example
### Describe the bug
In a nutshell: The time it takes the client to connect with the SSE is between 10 and up to 30 seconds. I dont know whats going on, but its not usable right now. I hope someone knows whats keeping the time to connect so high.
Regards
Alex
### Additional context
The source code on which Iam working on, but has the same issues:
import { addSyncClient, removeSyncClient } from "~/server/utils/sync";
Environment
Using NodeJs 21.6.2 and deployed on Vercel. Using chrome Version 124.0.6367.61 (Offizieller Build)
Reproduction
import { addSyncClient, removeSyncClient } from "~/server/utils/sync";
export default eventHandler(async (event) => {
const { boardId } = getRouterParams(event);
const { uniqueFingerprint } = getQuery(event);
if (!boardId || !uniqueFingerprint || typeof uniqueFingerprint !== "string") {
throw createError({
status: 400,
statusText: "Bad Request",
});
}
const eventStream = createEventStream(event);
// Add the client to the sync clients
addSyncClient(uniqueFingerprint, boardId.toString(), event.context.user ?? undefined, eventStream);
// Implement keep-alive mechanism
const keepAliveInterval = setInterval(() => {
eventStream.push("\n\nkeep-alive\n\n");
}, 10000); // Send a keep-alive comment every 10 seconds
eventStream.onClosed(async () => {
clearInterval(keepAliveInterval); // Clear the keep-alive interval
removeSyncClient(boardId.toString(), uniqueFingerprint);
await eventStream.close();
});
return eventStream.send();
});
The text was updated successfully, but these errors were encountered: