Fix race conditions in webhook response handling#672
Conversation
🦋 Changeset detectedLatest commit: e764695 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🌍 Community Worlds (10 failed)mongodb (1 failed):
starter (8 failed):
turso (1 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
74ec92d to
2f9461f
Compare
2d007e6 to
88ad5c9
Compare
2f9461f to
e764695
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a race condition in the streamer's readFromStream method where close events arriving during disk reads would immediately close the ReadableStream controller before all data was enqueued, potentially causing data loss.
Key changes:
- Added a
pendingCloseflag to buffer close events that arrive while reading from disk - Modified
closeListenerto set the flag instead of closing immediately when disk reads are in progress - Added logic to process buffered close events after disk reads and buffered event chunks are processed
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/world-local/src/streamer.ts | Implements the race condition fix by buffering close events during disk reads and processing them after disk reading completes |
| .changeset/webhook-response-body-fix.md | Documents the fix for the changeset |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Fixed a race condition in the streamer where close events could arrive during disk reads, causing premature controller closure. This fixes the flakiness in the
webhookWorkflowE2E test on "local" test suites.What changed?
pendingCloseflag to buffer close events that arrive during disk readingcloseListenerfunction to set this flag instead of immediately closing the controller when disk reads are in progressWhy make this change?
There was a race condition in the streamer where close events arriving during disk reads would close the controller before all data was enqueued. This could lead to incomplete data streams and potential data loss. This fix ensures that all data is properly processed before the stream is closed.