P
Prismaβ€’2mo ago
begot

Prisma Pulse not working after a while

i'm using Prisma Postgres and Prisma Pulse in my API. after a few hours, pulse stops functioning, while the normal database connection continues to work without issues. to resolve this, i have to manually visit the Prisma dashboard to disable and re-enable pulse, after which it starts working again. when pulse stops working, i encounter P6101 error codes in the console:
[Nest] 45216 - 01/30/2025, 8:05:45 PM ERROR [PulseService] Failed to initialize UserStatus stream:
[Nest] 45216 - 01/30/2025, 8:05:45 PM ERROR [PulseService] PrismaPulseDatasourceError: P6101 The connection to the database was momentarily interrupted. Prisma Pulse will attempt to reconnect to the database.
at PrismaPulseError.fromResponse (node_modules\@prisma\extension-pulse\dist\cjs\errors.js:23:20)
at WebSocket.<anonymous> (node_modules\@prisma\extension-pulse\dist\cjs\PulseSubscription.node.js:93:60)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
clientVersion: '6.3.0',
code: 'P6101',
details: undefined,
requestId: 'unknown'
}
[Nest] 45216 - 01/30/2025, 8:05:45 PM ERROR [PulseService] Failed to initialize UserStatus stream:
[Nest] 45216 - 01/30/2025, 8:05:45 PM ERROR [PulseService] PrismaPulseDatasourceError: P6101 The connection to the database was momentarily interrupted. Prisma Pulse will attempt to reconnect to the database.
at PrismaPulseError.fromResponse (node_modules\@prisma\extension-pulse\dist\cjs\errors.js:23:20)
at WebSocket.<anonymous> (node_modules\@prisma\extension-pulse\dist\cjs\PulseSubscription.node.js:93:60)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
clientVersion: '6.3.0',
code: 'P6101',
details: undefined,
requestId: 'unknown'
}
No description
16 Replies
Prisma AI Help
Prisma AI Helpβ€’2mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Nurul
Nurulβ€’2mo ago
Hey @1875 πŸ‘‹ Thank you for raising this issue here. I would like to take a look at the logs for your project to debug this issue. Can you let me know your email id or the GitHub handle with which you signed up? (Also, thanks for filling out the feedback form, our team has received the feedback πŸ™ )
begot
begotOPβ€’2mo ago
hey Nurul! it should be under "[email protected]" i'm very happy with Pulse so far, was able to implement real-time with ease in our dashboard and landing. would love to figure out what's going wrong here so we can move closer to using this in prod 😊 appreciate the quick response, and sorry for double posting. wasn't sure where would be appropriate to reach out πŸ˜…
Nurul
Nurulβ€’2mo ago
Thank you for sharing the email πŸ™ And no worries about double posting. We really appreciate you that you gave us feedback. This issue happens on Development environment of project named "Flawless", right?
begot
begotOPβ€’2mo ago
yeah, that’s correct
Nurul
Nurulβ€’2mo ago
Thanks for confirming. I do see intermittent disconnections. I have raised this with our PPg team. Please allow me to get back to you with an update as soon as possible
begot
begotOPβ€’2mo ago
take your time, and let me know if you need anything from my end. i’m happy to help and definitely understand. i’ve always been a Prisma user, been waiting for Pulse since it was announced. i don’t mind the extra wait if it means Prisma improves πŸ™
Nurul
Nurulβ€’4w ago
Thank you so much for your kind words and being a valued Prisma user. I will get back to you as soon as I have an update πŸ™Œ @1875 The issue should be fixed now. Can you test? We rolled out a fix yesterday
begot
begotOPβ€’4w ago
i will do some testing and report back
Nurul
Nurulβ€’4w ago
Great! Thank you for your assistance πŸ™
begot
begotOPβ€’4w ago
tested alongside other providers, and it seems fine. there are some minor throttles happening at times, is this expected on the free tier? yeah, it just started throttling pretty bad. this is what used to happen before it would reject the pulse streams.
prisma:query SELECT 1
prisma:query SELECT "public"."User"."id", "public"."User"."uid", "public"."User"."createdAt", "public"."User"."updatedAt", "public"."User"."username", "public"."User"."email", "public"."User"."password", "public"."User"."roles"::text[], "public"."User"."banned" FROM "public"."User" WHERE ("public"."User"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."User"."id" FROM "public"."User" WHERE ("public"."User"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."UserStatus"."id", "public"."UserStatus"."socketId", "public"."UserStatus"."status"::text, "public"."UserStatus"."product"::text, "public"."UserStatus"."userId", "public"."UserStatus"."connectedAt", "public"."UserStatus"."createdAt", "public"."UserStatus"."disconnectedAt", "public"."UserStatus"."lastSeen" FROM "public"."UserStatus" WHERE "public"."UserStatus"."userId" IN ($1) OFFSET $2
prisma:query INSERT INTO "public"."UserStatus" ("id","socketId","status","product","userId","connectedAt","createdAt","lastSeen") VALUES ($1,$2,CAST($3::text AS "public"."Status"),CAST($4::text AS "public"."Product"),$5,$6,$7,$8) ON CONFLICT ("userId") DO UPDATE SET "status" = CAST($9::text AS "public"."Status"), "socketId" = $10, "product" = CAST($11::text AS "public"."Product"), "lastSeen" = $12 WHERE ("public"."UserStatus"."userId" = $13 AND 1=1) RETURNING "public"."UserStatus"."id", "public"."UserStatus"."socketId", "public"."UserStatus"."status"::text, "public"."UserStatus"."product"::text, "public"."UserStatus"."userId", "public"."UserStatus"."connectedAt", "public"."UserStatus"."createdAt", "public"."UserStatus"."disconnectedAt", "public"."UserStatus"."lastSeen"
[Nest] 45788 - 02/05/2025, 3:34:48 PM LOG [GatewayService] client registered: 01JJXE3APWS2ADS3ZST8SVZNBK
prisma:query UPDATE "public"."UserStatus" SET "status" = CAST($1::text AS "public"."Status"), "socketId" = $2, "product" = $3, "lastSeen" = $4 WHERE ("public"."UserStatus"."userId" = $5 AND 1=1) RETURNING "public"."UserStatus"."id", "public"."UserStatus"."socketId", "public"."UserStatus"."status"::text, "public"."UserStatus"."product"::text, "public"."UserStatus"."userId", "public"."UserStatus"."connectedAt", "public"."UserStatus"."createdAt", "public"."UserStatus"."disconnectedAt", "public"."UserStatus"."lastSeen"
[Nest] 45788 - 02/05/2025, 3:38:48 PM LOG [GatewayService] client unregistered: 01JJXE3APWS2ADS3ZST8SVZNBK
prisma:query SELECT 1
prisma:query SELECT "public"."User"."id", "public"."User"."uid", "public"."User"."createdAt", "public"."User"."updatedAt", "public"."User"."username", "public"."User"."email", "public"."User"."password", "public"."User"."roles"::text[], "public"."User"."banned" FROM "public"."User" WHERE ("public"."User"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."User"."id" FROM "public"."User" WHERE ("public"."User"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."UserStatus"."id", "public"."UserStatus"."socketId", "public"."UserStatus"."status"::text, "public"."UserStatus"."product"::text, "public"."UserStatus"."userId", "public"."UserStatus"."connectedAt", "public"."UserStatus"."createdAt", "public"."UserStatus"."disconnectedAt", "public"."UserStatus"."lastSeen" FROM "public"."UserStatus" WHERE "public"."UserStatus"."userId" IN ($1) OFFSET $2
prisma:query INSERT INTO "public"."UserStatus" ("id","socketId","status","product","userId","connectedAt","createdAt","lastSeen") VALUES ($1,$2,CAST($3::text AS "public"."Status"),CAST($4::text AS "public"."Product"),$5,$6,$7,$8) ON CONFLICT ("userId") DO UPDATE SET "status" = CAST($9::text AS "public"."Status"), "socketId" = $10, "product" = CAST($11::text AS "public"."Product"), "lastSeen" = $12 WHERE ("public"."UserStatus"."userId" = $13 AND 1=1) RETURNING "public"."UserStatus"."id", "public"."UserStatus"."socketId", "public"."UserStatus"."status"::text, "public"."UserStatus"."product"::text, "public"."UserStatus"."userId", "public"."UserStatus"."connectedAt", "public"."UserStatus"."createdAt", "public"."UserStatus"."disconnectedAt", "public"."UserStatus"."lastSeen"
[Nest] 45788 - 02/05/2025, 3:34:48 PM LOG [GatewayService] client registered: 01JJXE3APWS2ADS3ZST8SVZNBK
prisma:query UPDATE "public"."UserStatus" SET "status" = CAST($1::text AS "public"."Status"), "socketId" = $2, "product" = $3, "lastSeen" = $4 WHERE ("public"."UserStatus"."userId" = $5 AND 1=1) RETURNING "public"."UserStatus"."id", "public"."UserStatus"."socketId", "public"."UserStatus"."status"::text, "public"."UserStatus"."product"::text, "public"."UserStatus"."userId", "public"."UserStatus"."connectedAt", "public"."UserStatus"."createdAt", "public"."UserStatus"."disconnectedAt", "public"."UserStatus"."lastSeen"
[Nest] 45788 - 02/05/2025, 3:38:48 PM LOG [GatewayService] client unregistered: 01JJXE3APWS2ADS3ZST8SVZNBK
as you can see, it never streamed any events for connecting
[Nest] 43868 - 02/05/2025, 10:30:23 PM DEBUG [PulseService] Emitting "user-status" event with action: update
[Nest] 43868 - 02/05/2025, 10:30:23 PM DEBUG [PulseService] Object(5) {
action: 'update',
after: {
id: '01JJXE4AYE2P86VD7EZF94VJ1F',
socketId: 'JpbHGeBXtflZPbDMAABG',
status: 'ONLINE',
product: 'FORTNITE',
userId: '01JJXE3APWS2ADS3ZST8SVZNBK',
connectedAt: 2025-01-31T07:09:43.569Z,
createdAt: 2025-01-31T07:09:43.569Z,
disconnectedAt: null,
lastSeen: 2025-02-05T21:30:23.768Z
},
before: null,
id: '01JKC0AX59ANYXH6BA6FCBNXND',
modelName: 'UserStatus'
}
[Nest] 43868 - 02/05/2025, 10:30:23 PM DEBUG [PulseService] Emitting "user-status" event with action: update
[Nest] 43868 - 02/05/2025, 10:30:23 PM DEBUG [PulseService] Object(5) {
action: 'update',
after: {
id: '01JJXE4AYE2P86VD7EZF94VJ1F',
socketId: 'JpbHGeBXtflZPbDMAABG',
status: 'ONLINE',
product: 'FORTNITE',
userId: '01JJXE3APWS2ADS3ZST8SVZNBK',
connectedAt: 2025-01-31T07:09:43.569Z,
createdAt: 2025-01-31T07:09:43.569Z,
disconnectedAt: null,
lastSeen: 2025-02-05T21:30:23.768Z
},
before: null,
id: '01JKC0AX59ANYXH6BA6FCBNXND',
modelName: 'UserStatus'
}
it should log like this ^
Nurul
Nurulβ€’4w ago
yeah, it just started throttling pretty bad.
If I understand correctly, you are not receiving events instantly, right? The events are throttled, so you are receiving events very delayed?
begot
begotOPβ€’4w ago
yeah, at times it takes several minutes to receive events, and by then they are all queued up and send all at once
Nurul
Nurulβ€’4w ago
Checked with pulse team:
given the way pulse is reconnecting now at 90seconds interval, it's an expected behavior. This is going to change once we finalize the ppg extension to push events on demand
So, for now this is expected, though this will change pretty soon and you can expect faster events. You won't notice this behaviour if your db is active and consistently sending events though:
the more the db is active, the less it's supposed to happen, though
begot
begotOPβ€’4w ago
i understand, though this was happening when i was doing pretty much constant tests. which is why i noticed it in the first place. it would stop updating the user status and throttle
begot
begotOPβ€’4w ago
following up on this. i just tested by sending repeated events, and it stopped streaming them entirely after a little while. i will attach the logs, and the events have not yet fired as of typing this

Did you find this page helpful?