Commit ec10700
feat(entities): log console.error when realtime broadcast is oversize (#167)
* feat(entities): auto-refetch when realtime broadcast is truncated
Server-side BASE-40236 slims oversize entity broadcasts to fit under the
Redis pubsub cap, signaling the slim with `_truncated: true` on the event
data. Customer apps that render the truncated fields would otherwise
display placeholder text until refresh.
The SDK now detects `_truncated` in `entities.X.subscribe` and transparently
refetches the full record over HTTP before invoking the user callback, so
deployed customer code keeps working without changes. Concurrent subscribers
in the same browser fan out to a single HTTP call via an in-flight
debounce keyed by `${entityName}:${id}:${timestamp}`. On refetch failure
the SDK falls through with the partial payload and logs a warning, so the
failure mode is no worse than today's drop-and-stale.
Delete events skip refetch — the record no longer exists.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(entities): rename _truncated → _oversize for stub flag
The wire flag is set only when the server falls back to a stub payload
because the original record was too big for realtime transport. Calling
it "truncated" was misleading — we don't truncate fields in that path,
we replace the whole payload with `{id, _oversize: true}`. `_oversize`
names the actual cause and tells the SDK why a refetch is needed.
Coordinated with the matching backend rename.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(entities): replace auto-refetch with console.error on _oversize
Per PM pushback, drop the HTTP auto-refetch path on oversize broadcasts —
even with debouncing, an entity that tens of subscribers all refetch on
every broadcast (e.g. a popular Truck record updated every 30 s in a
fleet app) shifts realtime load to HTTP at potentially uncapped fan-out.
New behavior: when `_oversize: true` is seen, log a single console.error
naming the entity, id, and the recommended `entities.X.get(id)` call so
the developer is notified at debug time. The user callback still fires
with the slimmed payload (big string fields are empty, rest of the
record may be the stub) — caller decides what to do.
Removed the inflightRefetches debounce map and refetchTruncated helper
since they're no longer needed.
Tests collapse from 5 refetch scenarios to 3 logging scenarios:
- logs and passes the stub through when _oversize is true
- does NOT log on delete events even if _oversize is set
- does NOT log when _oversize is absent
156/156 pass; lint + build clean.
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 5db5b5b commit ec10700
2 files changed
Lines changed: 126 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
200 | 216 | | |
201 | 217 | | |
202 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
210 | 320 | | |
211 | 321 | | |
212 | 322 | | |
| |||
0 commit comments