Skip to content

Get Error Messages when using Susie reply event #67

@chattes

Description

@chattes

Version: 2
Hi,
I am using version 2 and we get this error in server, although the mssage is delivered.

Debug: internal, implementation, error 
    Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at Object.internals.writeEvent (/home/ubuntu/bot-farm/node_modules/susie/lib/index.js:14:16)
    at Function.internals.handleEvent (/home/ubuntu/bot-farm/node_modules/susie/lib/index.js:69:15)
    at bound (domain.js:301:14)
    at Function.runBound [as event] (domain.js:314:12)
    at Redis.Subscriber.on (/home/ubuntu/bot-farm/routes/proxy/chatSSE.js:24:15)
    at emitTwo (events.js:130:20)
    at Redis.emit (events.js:213:7)
    at Redis.exports.returnReply (/home/ubuntu/bot-farm/node_modules/ioredis/lib/redis/parser.js:107:14)
    at JavascriptRedisParser.returnReply (/home/ubuntu/bot-farm/node_modules/ioredis/lib/redis/parser.js:27:13)
    at JavascriptRedisParser.execute (/home/ubuntu/bot-farm/node_modules/redis-parser/lib/parser.js:574:12)
    at Socket.<anonymous> (/home/ubuntu/bot-farm/node_modules/ioredis/lib/redis/event_handler.js:107:22)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:266:12)

This is the route code

  handler: (req, reply) => {
    const { query: { user: channel } } = req
    console.log('Received Ping', channel)
    let payload = req.payload
    // const stream = new PassThrough({ objectMode: true })
    if (R.not(R.isNil(Subscriber))) {
      Subscriber.on('message', (channel, message) => {
        const messageParsed = JSON.parse(message)
        reply.event({ event: channel, data: messageParsed })
        // stream.write({ data: messageParsed })
      })
      Subscriber.subscribe(channel)
    }
    reply.event({ event: channel, data: null })
    // reply.event(stream, null, { event: channel })
  },

When I use stream it does not come, although stream mixes up multiple clients connecting to the server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions