bnussman / beep

Monorepo for Ride Beep App. Ride Beep App 🚕 is a rideshare platform for college students at any colleges and university.
https://ridebeep.app
21 stars 10 forks source link

bug: tRPC subscription error casuing API to crash in production #99

Closed bnussman closed 1 month ago

bnussman commented 2 months ago

When there is some load on the API, the API crashes with this error. We should try to figure out why and fix it. It may be a bun issue because we are running an old version of bun or something more serious

100 |     let unsub = null;
101 |     return new ReadableStream({
102 |         start (controller) {
103 |             unsub = observable.subscribe({
104 |                 next (data) {
105 |                     controller.enqueue(data);
                          ^
TypeError: ReadableStreamDefaultController is not in a state where chunk can be enqueued
      at enqueue (:1:21)
      at next (/usr/api/node_modules/@trpc/server/dist/observable/observable.mjs:105:21)
      at next (/usr/api/node_modules/@trpc/server/dist/observable/observable.mjs:31:21)
      at onLocation (/usr/api/src/routers/rider.ts:276:13)
      at _PubSub_emitPubSubMessage (/usr/api/node_modules/@redis/client/dist/lib/client/pub-sub.js:304:9)
      at handleMessageReply (/usr/api/node_modules/@redis/client/dist/lib/client/pub-sub.js:237:13)
      at onReply (/usr/api/node_modules/@redis/client/dist/lib/client/commands-queue.js:40:25)
      at write (/usr/api/node_modules/@redis/client/dist/lib/client/RESP2/decoder.js:119:13)
      at onReplyChunk (/usr/api/node_modules/@redis/client/dist/lib/client/commands-queue.js:154:9)
      at /usr/api/node_modules/@redis/client/dist/lib/client/index.js:421:29
bnussman commented 1 month ago

Fixed by upgrading bun I think, but getting segfaults every once in a while now