Skip to content

Add electric-has-data response header#3851

Open
balegas wants to merge 1 commit intomainfrom
vbalegas/track-empty-responses
Open

Add electric-has-data response header#3851
balegas wants to merge 1 commit intomainfrom
vbalegas/track-empty-responses

Conversation

@balegas
Copy link
Contributor

@balegas balegas commented Feb 16, 2026

Summary

  • Adds a new electric-has-data response header ("true" / "false") to all successful shape responses, allowing operators to distinguish data-bearing from empty responses without parsing bodies
  • Fixes the :now offset path to correctly set no_changes: true on the response
  • Auto-exposes the new header via CORS by adding it to @electric_headers

Fixes #3850

Test plan

  • Added refute response.no_changes assertion on data response test in api_test.exs
  • Added assert response.no_changes assertion on "now" offset and long-poll timeout tests in api_test.exs
  • Added electric-has-data header assertions in serve_shape_plug_test.exs for data responses ("true") and empty responses ("false")
  • CORS test passes automatically since header is in @electric_headers
  • All 70 tests pass

🤖 Generated with Claude Code

…esponses

All successful live shape responses return HTTP 200 regardless of whether they
carry data or only control messages. This adds an `electric-has-data` header
("true"/"false") so operators can filter data-bearing vs empty responses without
parsing bodies. Fixes #3850.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.17%. Comparing base (b3ae567) to head (0bcd48f).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3851       +/-   ##
===========================================
+ Coverage   69.43%   87.17%   +17.74%     
===========================================
  Files           6       25       +19     
  Lines         386     2308     +1922     
  Branches       96      577      +481     
===========================================
+ Hits          268     2012     +1744     
- Misses        117      294      +177     
- Partials        1        2        +1     
Flag Coverage Δ
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (?)
packages/start 82.83% <ø> (?)
packages/typescript-client 92.07% <ø> (?)
packages/y-electric 56.05% <ø> (ø)
typescript 87.17% <ø> (+17.74%) ⬆️
unit-tests 87.17% <ø> (+17.74%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blacksmith-sh

This comment has been minimized.

@balegas balegas requested a review from KyleAMathews February 16, 2026 15:04
@balegas
Copy link
Contributor Author

balegas commented Feb 16, 2026

@KyleAMathews I want to add this header to be able to filter out live requests with no data in OTEL. You might have opinions about it.

I don't think the latency or the amount of these requests are useful for observability and removing them would remove a lot of noise from our dashboards

@balegas balegas self-assigned this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add electric-has-data response header to distinguish empty live responses

1 participant