Skip to content

Çok satırlı (multiline) mesajlar WebSocket JSON parse hatasına ve process çökmesine sebep oluyor #4

Description

@emrullahctrl

Bir kullanıcı, birden fazla satırdan oluşan bir mesaj gönderdiğinde (mesaj içinde literal \n newline karakteri geçtiğinde), kütüphane gelen WebSocket verisini JSON.parse() ile işlerken hata fırlatıyor ve bu hata yakalanmadığı (try/catch içine alınmadığı) için tüm bot process'i çöküyor.

Hata çıktısı:

SyntaxError: Bad control character in string literal in JSON at position 47 (line 1 column 48)
    at JSON.parse (<anonymous>)
    at WebSocket.<anonymous> (node_modules/topluyo-bot/index.js:329:28)
    at WebSocket.emit (node:events:519:28)
    at Receiver.receiverOnMessage (node_modules/ws/lib/websocket.js:1239:20)
    ...

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions