Commit 25f3fea
committed
fix(core): enhance zodSocket protocol detection to prevent message corruption
Fixed a critical bug where user messages containing a 'payload' property
were incorrectly identified as protocol-wrapped messages, causing data loss.
Changes:
- Enhanced hasValidPayload check to require both 'payload' AND 'version'
- Added isObject() helper to exclude arrays and null values
- Refactored message normalization into dedicated normalizeMessage() method
- Added comprehensive test suite with 11 test cases covering all edge cases
The fix ensures that only messages with the full protocol signature
(version + payload as object) are treated as wrapped messages.
Fixes: Protocol ambiguity where user data with 'payload' field was misinterpreted
Tests: 11/11 passing, including edge cases for non-object payloads and missing version1 parent aa69b90 commit 25f3fea
2 files changed
+419
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| |||
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
190 | 218 | | |
191 | 219 | | |
192 | 220 | | |
| |||
206 | 234 | | |
207 | 235 | | |
208 | 236 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 237 | + | |
| 238 | + | |
217 | 239 | | |
218 | 240 | | |
219 | 241 | | |
| |||
0 commit comments