Zigbee2MQTT crash with "Error: write after end" when using Sonoff Dongle-M (MAX)
What happened?
Zigbee2MQTT crashes with the following error:
/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:264`
var er = new ERR_STREAM_WRITE_AFTER_END();
^
Error: write after end
at writeAfterEnd (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:264:12)
at File.Writable.write (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:300:21)
at DerivedLogger.ondata (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_readable.js:629:20)
at DerivedLogger.emit (node:events:531:35)
at DerivedLogger.Readable.read (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_readable.js:451:26)
at flow (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_readable.js:858:34)
at File.pipeOnDrainFunctionResult (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_readable.js:690:7)
at File.emit (node:events:519:28)
at onwriteDrain (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:453:12)
at afterWrite (/app/node_modules/.pnpm/[email protected]/node_modules/readable-stream/lib/_stream_writable.js:441:18)After the crash Zigbee2MQTT restarts and reconnects to the adapter again.
From the adapter logs it looks like the TCP connection is repeatedly closed by the client:
tcp_server: TCP connection closed by peer z2mOrZhaConnected: false
A few seconds later Zigbee2MQTT reconnects again.
The dongle itself does not reboot and continues running normally. Memory and firmware logs look stable.
Environment:
Zigbee2MQTT version: 2.9.1-1 Adapter: Sonoff Dongle-M (Dongle-MAX) Chip: EFR32MG21 Driver: ember
Zigbee2mqtt / configuration.yaml
serial:
port: tcp://ZigbeeAP-COOR-CHOD.local:6638
baudrate: 115200
adapter: ember
rtscts: false
It seems that Zigbee2MQTT crashes internally and closes the connection to the adapter which then reconnects again.
What did you expect to happen?
Zigbee2MQTT should continue running normally without crashing and maintain a stable connection to the Sonoff Dongle-M adapter.
How to reproduce it (minimal and precise)
No response
Zigbee2MQTT version
2.9.1-1
Adapter firmware version
Firmware Version: V1.0.0 (SDK Version 7.4.5)
Adapter
Sonoff Dongle-M (EFR32MG24) using ember driver
Setup
Raspberry Pi 4 Home Assistant OS Core 2026.3.1 Supervisor 2026.02.3 Operativo System 17.1 Frontend 20260304.0
Zigbee2MQTT Home Assistant add-on System running from SSD
Coordinator: Sonoff Dongle-M (EFR32MG24) Firmware: SDK 7.4.5 Driver: ember
Device database.db entry
No response
Debug log
45df7312_zigbee2mqtt_2026-03-13T09-19-53.483Z.log
Notes
No response
Source: Koenkk/zigbee2mqtt