xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.19k stars 372 forks source link

StreamManagement extension broken #822

Closed NtTestAlert closed 4 years ago

NtTestAlert commented 4 years ago

versions 0.10.0, 0.11.0

If another stanza is received after sending (for example re-sent due to resuming session...) the entire connection crashes. https://xmpp.org/extensions/xep-0198.html does not guarantee the order, it just states that the server MUST reply with or , and how could it guarantee the order in which the client processes the incoming messages if some are pending? This breaks the entire client for ejabberd.

problematic code in package stream-management:

  const response = await entity.sendReceive(
    xml('enable', {xmlns: NS, max, resume: resume ? 'true' : undefined})
  )

  if (!response.is('enabled')) {
    throw StanzaError.fromElement(response)
  }

sample error:


⮊ <enable xmlns="urn:xmpp:sm:3"/>
⮈ <message to='testxxx@test.ing/test' from='testxxx@test.ing'><result id='1581775987351547' queryid='0whpu52456' xmlns='urn:xmpp:mam:2'><forwarded xmlns='urn:xmpp:forward:0'><message xml:lang='en' to='testxxx@test.ing/test' from='root@test.ing/gajim.AB98C175' type='chat' id='8be4d693-d0e9-400b-a7b9-8eb5c55af7c0' xmlns='jabber:client'><archived by='testxxx@test.ing' id='1581775987351547' xmlns='urn:xmpp:mam:tmp'/><stanza-id by='testxxx@test.ing' id='1581775987351547' xmlns='urn:xmpp:sid:0'/><origin-id xmlns='urn:xmpp:sid:0' id='8be4d693-d0e9-400b-a7b9-8eb5c55af7c0'/><request xmlns='urn:xmpp:receipts'/><body>asdas</body><thread>hnKEpbmgQgpuBYafyKDlVhKjlvxwcxCw</thread></message><delay from='test.ing' stamp='2020-02-15T14:13:07.351547Z' xmlns='urn:xmpp:delay'/></forwarded></result><delay from='test.ing' stamp='2020-02-15T15:10:16.262977Z' xmlns='urn:xmpp:delay'>Resent</delay></message>
StanzaError: result
⮈ <enabled xmlns='urn:xmpp:sm:3'/>
    at Function.fromElement (C:\Workspace\xmpp\node_modules\@xmpp\error\index.js:27:19)
    at Function.fromElement (C:\Workspace\xmpp\node_modules\@xmpp\middleware\lib\StanzaError.js:15:25)
    at enable (C:\Workspace\xmpp\node_modules\@xmpp\stream-management\index.js:16:23)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async C:\Workspace\xmpp\node_modules\@xmpp\stream-management\index.js:102:22
    at async C:\Workspace\xmpp\node_modules\@xmpp\stream-features\route.js:8:21 {

the only way to fix it is to comment out the module by hand

sonnyp commented 4 years ago

@NtTestAlert which ejabberd version? can you share the output of https://github.com/xmppjs/xmpp.js/tree/master/packages/debug ?

sonnyp commented 4 years ago

Can you also share your code? At least the part that triggers the connection and MAM query.

sonnyp commented 4 years ago

nevermind I undestood the issue. Sorry I overlooked the XEP. On it.

sonnyp commented 4 years ago

Thanks for the bug report https://github.com/xmppjs/xmpp.js/pull/823

sonnyp commented 4 years ago

released 0.11.1