Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes API crashes when listening #2

Open
ghost opened this issue Apr 9, 2021 · 9 comments
Open

Sometimes API crashes when listening #2

ghost opened this issue Apr 9, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Apr 9, 2021

Error: There was an unknown WS error. Contact the dev team about this (error code 935470). Original error: Error: unrecognized attach_file of type undefined
@ghost ghost changed the title Sometims API crashes when listening Sometimes API crashes when listening Apr 9, 2021
@ghost
Copy link
Author

ghost commented Apr 9, 2021

Also different one:

Error: There was an unknown WS error. Contact the dev team about this (error code 935468). Original error: TypeError: Cannot read property 'substring' of undefined.

@makara-filip
Copy link
Owner

Hi. We highly appreciate you posting this issue.

According to the error code, it seems like there was an error while parsing an incoming reply message with an attachment.
We are currently working on fixing all problems related to attachments.
We will let you know when it's fixed.

@samostanek samostanek added the bug Something isn't working label Apr 9, 2021
@ghost
Copy link
Author

ghost commented Apr 9, 2021

Another crash:

ERR! err read ECONNRESET
node:events:346
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:211:20)
Emitted 'error' event at:
    at MqttClient.<anonymous> (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\dist\lib\api.js:255:36)
    at MqttClient.emit (node:events:369:20)
    at Duplexify.streamErrorHandler (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:343:12)
    at Duplexify.emit (node:events:369:20)
    at Duplexify._destroy (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\index.js:191:15)
    at C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\index.js:182:10
    at processTicksAndRejections (node:internal/process/task_queues:76:11) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read',
  type: 'error',
  target: WebSocket {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    readyState: 3,
    bytesReceived: 135057,
    extensions: null,
    protocol: '',
    _binaryType: 'arraybuffer',
    _finalize: [Function: bound finalize] { __ultron: 0 },
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: '',
    _closeTimer: null,
    _finalized: true,
    _closeCode: 1006,
    _receiver: null,
    _sender: null,
    _socket: null,
    _ultron: null,
    protocolVersion: 13,
    _isServer: false,
    url: 'wss://edge-chat.facebook.com/chat?sid=213667968948676',
    _req: null,
    [Symbol(kCapture)]: false
  }
}
[nodemon] app crashed - waiting for file changes before starting...

@ghost
Copy link
Author

ghost commented Apr 9, 2021

And next one 😄

ERR! err Connection refused: Server unavailable
node:events:346
      throw er; // Unhandled 'error' event
      ^

Error: Connection refused: Server unavailable
    at MqttClient._handleConnack (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:1190:15)
    at MqttClient._handlePacket (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:424:12)
    at work (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:321:12)
    at Writable.writable._write (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:335:5)
    at doWrite (C:\Users\KMatuszak\Documents\bot\node_modules\readable-stream\lib\_stream_writable.js:409:139)
    at writeOrBuffer (C:\Users\KMatuszak\Documents\bot\node_modules\readable-stream\lib\_stream_writable.js:398:5)
    at Writable.write (C:\Users\KMatuszak\Documents\bot\node_modules\readable-stream\lib\_stream_writable.js:307:11)
    at Duplexify.ondata (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:619:20)
    at Duplexify.emit (node:events:369:20)
    at addChunk (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:291:12)
    at readableAddChunk (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:278:11)
    at Duplexify.Readable.push (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\node_modules\readable-stream\lib\_stream_readable.js:245:10)
    at Duplexify._forward (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\index.js:170:26)
    at Transform.onreadable (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\index.js:134:10)
    at Transform.emit (node:events:369:20)
    at emitReadable_ (C:\Users\KMatuszak\Documents\bot\node_modules\websocket-stream\node_modules\readable-stream\lib\_stream_readable.js:504:10)
Emitted 'error' event at:
    at MqttClient.<anonymous> (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\dist\lib\api.js:255:36)
    at MqttClient.emit (node:events:369:20)
    at MqttClient._handleConnack (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:1192:10)
    at MqttClient._handlePacket (C:\Users\KMatuszak\Documents\bot\node_modules\ts-messenger-api\node_modules\mqtt\lib\client.js:424:12)
    [... lines matching original stack trace ...]
    at Transform.onreadable (C:\Users\KMatuszak\Documents\bot\node_modules\duplexify\index.js:134:10) {
  code: 3
}
[nodemon] app crashed - waiting for file changes before starting...

@makara-filip
Copy link
Owner

You are just warming up, right? :-)
The two multi-line errors were caused by a websocket connection failure. When you debug and pause on a breakpoint, the websocket client loves to disconnect after some time. It occurs often when handling this type of connection.

@ghost
Copy link
Author

ghost commented Apr 9, 2021

I didn't debugged or paused on a breakpoint. My app was listening for some longer time, and unexpectedly crashed.

@ghost
Copy link
Author

ghost commented Apr 9, 2021

The ERR! err Connection refused: Server unavailable crash happened for the second time now, let me know if you want me to inform you about these crashes.

@ghost
Copy link
Author

ghost commented Apr 10, 2021

Error: There was an unknown WS error. Contact the dev team about this (error code 935470). Original error: TypeError: Cannot read property 'messageMetadata' of undefined.

@samostanek
Copy link
Collaborator

I think the MqttClient crashes are Facebook's issue. We need to add reconnect logic, but that will take some time. Until then, you will have to implement reconnect logic outside this package. (Or submit a PR :) )

makara-filip added a commit that referenced this issue Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants