jisoon
jisoon
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
Thank you btw
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
hello @Nurul (Prisma) sorry for the very late reply, I commented the socket part and there is no error. I think it only appear when the socket is on.
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
Hello @Nurul. May I kindly ask if there are any updates? Thank you!
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
yes the pulse events are working
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
i actually just copied the example implementation from prisma pulse docs
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
this is the example server that i created https://github.com/COROTANjayson/prisma-pulse-test
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
yes
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
yeah i still get the same error using stream(); i am using "prisma": "^5.14.0", and "@prisma/extension-pulse": "^1.1.0",
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
yes @Nurul (Prisma) I still facing this issue
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
this is how i implemented in my sveltekit app
onMount(() => {
const url = 'http://localhost:3000';

const socket = io(url);
socket.on('todo_added', async (event: any) => {
console.log('received UPDATE event from server', event);
todos.push(event.created);
let resp = await axios.get(`/api/issue`);
todos = resp.data.issues;
});

return () => {
socket.off('issue_added');
};
});
onMount(() => {
const url = 'http://localhost:3000';

const socket = io(url);
socket.on('todo_added', async (event: any) => {
console.log('received UPDATE event from server', event);
todos.push(event.created);
let resp = await axios.get(`/api/issue`);
todos = resp.data.issues;
});

return () => {
socket.off('issue_added');
};
});
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
I just started using pulse last week, and that error kept showing. Whenever I started the server, the pulse worked for some minutes, then the MaxListenerExceedWarningError kept appearing and then crashed. @batmanwholaughz
23 replies
PPrisma
Created by jisoon on 6/6/2024 in #help-and-questions
Websocket error when using Pulse
My code:
require("dotenv").config();
import express from "express";
import { createServer } from "http";
import { Server, Socket } from "socket.io";

import prisma from "../prisma/prisma";


const port = process.env.APP_PORT || 3000;

const app = express();
const server = createServer(app);

const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"],
},
});
io.on("connection", async (socket) => {});

export async function streamTodo(io: Server) {
await prisma.$disconnect();
console.log("streamTodo");

const stream = await prisma.todo.subscribe();

// Handle Prisma stream events
for await (const event of stream) {
console.log(`received event: `, event);

if (event.action === "create") {
io.sockets.emit("todo_added", event);
}
}
}

server.listen(port, async () => {
streamTodo(io);
});
require("dotenv").config();
import express from "express";
import { createServer } from "http";
import { Server, Socket } from "socket.io";

import prisma from "../prisma/prisma";


const port = process.env.APP_PORT || 3000;

const app = express();
const server = createServer(app);

const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"],
},
});
io.on("connection", async (socket) => {});

export async function streamTodo(io: Server) {
await prisma.$disconnect();
console.log("streamTodo");

const stream = await prisma.todo.subscribe();

// Handle Prisma stream events
for await (const event of stream) {
console.log(`received event: `, event);

if (event.action === "create") {
io.sockets.emit("todo_added", event);
}
}
}

server.listen(port, async () => {
streamTodo(io);
});
23 replies