Open sanduluca opened 1 month ago
@sanduluca what was the previous working version you were using? What are the steps to reproduce the issue? Does it happens randomly?
We were not using the mqtt before this. We could not reproduce this. Yes. It seems to happen randomly. We have 2-5 crashes a day on a 1000+ users daily
It's hard based on that log to say what could trigger that, could you try to at least provide me a valid stack trace? Something that points me to the line that is triggering the issue.
IMO giving that we treat react native as a browser and it is using wss
the error cold be in this two places:
I dunno if adding a check before the push could fix the issue
@mcollina any hint?
Try using version 5.9.1
Ok, after releasing a few new updates to our users with new mqtt version we still receive JavascriptException: Error: stream.push() after EOF
// package.json
"mqtt": "^5.9.1",
// yarn.lock
mqtt-packet@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/mqtt-packet/-/mqtt-packet-9.0.0.tgz#fd841854d8c0f1f5211b00de388c4ced45b59216"
integrity sha512-8v+HkX+fwbodsWAZIZTI074XIoxVBOmPeggQuDFCGg1SqNcC+uoRMWu7J6QlJPqIUIJXmjNYYHxBBLr1Y/Df4w==
dependencies:
bl "^6.0.8"
debug "^4.3.4"
process-nextick-args "^2.0.1"
mqtt@^5.2.0, mqtt@^5.9.1:
version "5.9.1"
resolved "https://registry.yarnpkg.com/mqtt/-/mqtt-5.9.1.tgz#422ded61d432b995d931ae4d9c470684f33e3289"
integrity sha512-FMENfSUMfCSUCnkuUVAL4U01795SUEfrX0NZ53HNr1r2VNpwKhR5Au9viq9WCFGtgrDAmsll4fkloqFCFgStYA==
dependencies:
"@types/readable-stream" "^4.0.5"
"@types/ws" "^8.5.9"
commist "^3.2.0"
concat-stream "^2.0.0"
debug "^4.3.4"
help-me "^5.0.0"
lru-cache "^10.0.1"
minimist "^1.2.8"
mqtt "^5.2.0"
mqtt-packet "^9.0.0"
number-allocator "^1.0.14"
readable-stream "^4.4.2"
reinterval "^1.1.0"
rfdc "^1.3.0"
split2 "^4.2.0"
worker-timers "^7.1.4"
ws "^8.17.1"
The error seems to come from onMessage
Fatal Exception: com.facebook.react.common.JavascriptException
Error: stream.push() after EOF, js engine: hermes, stack: anonymous@1:3472651 NodeError@1:3473631 readableAddChunk@1:3484528 anonymous@1:3488655 onMessage@1:3684762 dispatchEvent@1:265253 anonymous@1:287806 emit@1:123298 emit@1:121941 __callFunction@1:115290 anonymous@1:113595 __guard@1:114551 callFunctionReturnFlushedQueue@1:113553
@sanduluca I'm sorry but I'm not able to reproduce this issue anyway, could you try to fix this yourself and submit a PR? For what I know that issue happens when writing to a stream that is destroyed and the check is there now, no clue whatever could cause that :(
there is also another check here
As the proxy could be a buffered duplex so there are 2 sreams to handle
I am not able to reproduce it constantly either. I caught it myself for the first time yesterday. Here is a screenshot:
Anyway, I was searching what we can do and found a possible solution. Opened a PR for this
MQTTjs Version
5.8.0
Broker
AWS
Environment
React Native (engine: Hermes)
Description
After releasing a new version of out react native app with the mqtt feature we started receiving crashes in Firebase crashlytics.
This is the only issue I found related to this problem https://github.com/nodejs/readable-stream/issues/207
Code
```tsx // mqtt.tsx import React, { createContext, useContext } from 'react'; import mqtt from 'mqtt'; import useMqttConnection, { MqttError, MqttStatus } from 'hooks/useMqttConnection'; import { useAppSelector } from 'store'; interface MqttContextValue { mqttClient: mqtt.MqttClient | null; mqttStatus: MqttStatus; mqttError: MqttError | null; subscribeToTopic: (topic: string, ops?: mqtt.IClientSubscribeOptions) => void; } // @ts-ignore const MqttContext = createContextMinimal Reproduction
Unfortunately we cannot reproduce this locally. We are only recording crashes in Firebase Crashlytics
Debug logs