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

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'write') #1058

Open
filipw01 opened this issue Jan 17, 2025 · 4 comments

Comments

@filipw01
Copy link

⚠ If you need help with XMPP itself, please visit https://xmpp.org/community/ instead.

It looks like socket can be possibly null while Client.write is called

Image

Error stack trace

VM4851 chunk-QKGHVZFU.js:317 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'write')
    at VM4851 chunk-QKGHVZFU.js:317:23
    at new Promise (<anonymous>)
    at Client.write (VM4851 chunk-QKGHVZFU.js:312:16)
    at Client.send (VM4851 chunk-QKGHVZFU.js:302:20)
    at Client.send (VM4734 @xmpp_websocket.js:152:22)
    at Client.send (VM4733 @xmpp_client-core.js:29:46)
    at IQCaller.request (VM4737 @xmpp_iq_caller.js:93:29)
    at IQCaller._childRequest (VM4737 @xmpp_iq_caller.js:106:21)
    at IQCaller.set (VM4737 @xmpp_iq_caller.js:114:21)
    at bind (VM4743 @xmpp_resource-binding.js:19:37)

A clear and concise description of what the bug is.

@xmpp/client: 0.13.1

@sonnyp
Copy link
Member

sonnyp commented Jan 17, 2025

how do you reproduce? this might be a bug in your code

@sonnyp
Copy link
Member

sonnyp commented Jan 17, 2025

ie - don't call send or write if you're not connected

@filipw01
Copy link
Author

Sadly I don't have a nice reproduction. Looking at the stack trace I suspect this is originating from resource binding

const result = await iqCaller.set(makeBindElement(resource));
perhaps some race condition when client disconnects

@sonnyp
Copy link
Member

sonnyp commented Jan 17, 2025

We'll need to find with certainty the source of the exception. Then understand why it is uncaught.

A good starting place is to check if a stream feature throwing results in an uncuaght exception

https://github.com/xmppjs/xmpp.js/blob/main/packages/stream-features/index.js (this is what resource biding uses so that's a good usage example

stream-features is the only module without tests so it could also benefit from that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants