Skip to content

FIX: don't drop requests that arrive before v8_roundtrip is re-entered - #440

Merged
SamSaffron merged 1 commit into
mainfrom
fix-roundtrip-request-drop
Aug 11, 2026
Merged

FIX: don't drop requests that arrive before v8_roundtrip is re-entered#440
SamSaffron merged 1 commit into
mainfrom
fix-roundtrip-request-drop

Conversation

@davidtaylorhq

Copy link
Copy Markdown
Collaborator

When an attached Ruby callback makes its own request on the same context (perform_microtask_checkpoint, a nested call, etc), the Ruby thread can enqueue its next request in the gap between the nested dispatch finishing and the V8 thread re-entering v8_roundtrip. The buf_reset(&c->req) on entry then destroyed that request, leaving both threads waiting on each other forever.

The reset is a leftover from before 478c763, when v8_roundtrip returned a pointer into the live request buffer and had to clear it on the next entry. Requests are now handed off with buf_move, so the buffer is already empty on re-entry unless it holds a new, unread message.

Writing a deterministic test here is very difficult. I was only able to reproduce by looping thousands of times.

When an attached Ruby callback makes its own request on the same context (perform_microtask_checkpoint, a nested call, etc), the Ruby thread can enqueue its next request in the gap between the nested dispatch finishing and the V8 thread re-entering v8_roundtrip. The buf_reset(&c->req) on entry then destroyed that request, leaving both threads waiting on each other forever.

The reset is a leftover from before 478c763, when v8_roundtrip returned a pointer into the live request buffer and had to clear it on the next entry. Requests are now handed off with buf_move, so the buffer is already empty on re-entry unless it holds a new, unread message.
@SamSaffron
SamSaffron merged commit 14209e3 into main Aug 11, 2026
30 checks passed
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.

2 participants