Skip to content

Migrate deprecated Async::Variable to Async::Promise#226

Merged
ioquatix merged 2 commits into
socketry:mainfrom
jasl:patch-1
Jul 12, 2026
Merged

Migrate deprecated Async::Variable to Async::Promise#226
ioquatix merged 2 commits into
socketry:mainfrom
jasl:patch-1

Conversation

@jasl

@jasl jasl commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Async::Variable is deprecated in favour of Async::Promise, producing:

Async::Variable is deprecated, use Async::Promise instead.

Simply renaming the class is not enough. Async::Promise does not provide the value= writer that Async::Variable aliased to resolve, so the completion signal @closed.value = true in Finishable#close has to become @closed.resolve(true) — otherwise closing an HTTP/1 body that has been read raises NoMethodError, breaking normal request handling. Thanks to the Codex review for catching this.

Changes

  • http1/finishable.rb: use Async::Promise and resolve(true) to signal completion.
  • Dependency: raise async to >= 2.35.1.
    • Async::Promise was introduced in async 2.29.0, so the previous floor (>= 2.10.2) could not load it.
    • 2.35.1 additionally fixes a spurious-wakeup bug in Async::Promise#wait — the exact indefinite wait path Finishable#wait relies on to block until the body is fully consumed before a persistent connection is reused. (Happy to relax this to >= 2.29.0 if you'd prefer a lower floor.)
  • Test fixtures: migrate the remaining Async::Variable usages (a_protocol.rb and two HTTP/2 tests).
  • Adjacent cleanup: while editing a_protocol.rb, replace two other deprecated calls — Async::Reactor.run{}Async{} and Async::Task#sleepKernel#sleep.

I left the version bump and releases.md entry for you to handle as part of your release flow.

Verification

  • Full sus suite passes (227 passed / 3 skipped), unchanged from main.
  • Under ruby -w, no deprecation warnings originate from async-http's own code (the only remaining one comes from the external sus-fixtures-async gem).
  • RuboCop clean.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a91f024239

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/async/http/protocol/http1/finishable.rb
@jasl

jasl commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

OK, I thought it was just a rename, I'll do a proper fix this weekend.

`Async::Variable` is deprecated in favour of `Async::Promise`. Renaming the
class alone is not enough: `Async::Promise` has no `value=` writer, so the
completion signal `@closed.value = true` must become `@closed.resolve(true)`,
otherwise closing a read HTTP/1 body raises `NoMethodError`.

- finishable.rb: use `Async::Promise` and `resolve(true)` to signal completion.
- Raise the async dependency to `>= 2.35.1`. `Async::Promise` was introduced in
  2.29.0, and 2.35.1 fixes a spurious-wakeup bug in `Async::Promise#wait` — the
  exact indefinite wait path `Finishable#wait` relies on.
- Migrate the remaining `Async::Variable` usages in the test fixtures.
- Clean up adjacent deprecations in the fixture along the way
  (`Async::Reactor.run{}` -> `Async{}`, `Async::Task#sleep` -> `Kernel#sleep`).
@jasl jasl changed the title Fix deprecates warning Migrate deprecated Async::Variable to Async::Promise Jul 11, 2026
@jasl

jasl commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@samuel-williams-shopify
Could you take a look?

Note: Claude helps me make the patch

@ioquatix ioquatix merged commit cd9bb03 into socketry:main Jul 12, 2026
17 of 20 checks passed
@ioquatix

Copy link
Copy Markdown
Member

Thanks for this, nice work.

@jasl jasl deleted the patch-1 branch July 12, 2026 11:18
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