Skip to content

Preserve worker pool control flow during cancellation - #209

Merged
ioquatix merged 3 commits into
socketry:mainfrom
rwstauner:nil-errinfo
Aug 14, 2026
Merged

Preserve worker pool control flow during cancellation#209
ioquatix merged 3 commits into
socketry:mainfrom
rwstauner:nil-errinfo

Conversation

@rwstauner

@rwstauner rwstauner commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

It is possible for subsequent iterations of the worker-pool wait loop to clear the pending Ruby control-flow state before it can be rethrown.

Use rb_ensure so Ruby preserves the complete opaque jump state while the ensure callback cancels and drains unfinished work. Errors or other non-local exits raised while draining are discarded, after which Ruby restores and rethrows the original state.

The tests cover both an exception followed by an internal rescue and a throw followed by an internal rescue.

See also https://bugs.ruby-lang.org/issues/22240

Types of Changes

  • Bug fix.

Contribution

It's possible for subsequent iterations of the loop to clear errinfo
before we call rb_jump_tag with state so we should preserve both.

See also https://bugs.ruby-lang.org/issues/22240
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Assisted-By: devx/ba580080-a8e3-4866-9330-83d33d37746c
@samuel-williams-shopify samuel-williams-shopify changed the title Save and restore errinfo along with state in worker_pool_call Preserve worker pool control flow during cancellation Aug 14, 2026
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Assisted-By: devx/ba580080-a8e3-4866-9330-83d33d37746c
@ioquatix
ioquatix merged commit 5f891a4 into socketry:main Aug 14, 2026
27 of 30 checks passed
@ioquatix ioquatix added this to the v1.19.5 milestone Aug 14, 2026
@ioquatix

Copy link
Copy Markdown
Member

Can you let me know if this solved your problem?

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.

3 participants