Skip to content

Add a timeout option to HttpClientRequest #4709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: next-minor
Choose a base branch
from

Conversation

thewilkybarkid
Copy link
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Adds a timeout option to HttpClientRequest, which results in a Transport RequestError if it's exceeded. I've erred on adding to the request rather than having it alongside to cater for cases where the client has been composed.

I'm sure that some of the implementation could be improved. 😄

Related

Copy link

changeset-bot bot commented Apr 10, 2025

🦋 Changeset detected

Latest commit: 06917f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@effect/platform Minor
@effect/cli Major
@effect/cluster Major
@effect/experimental Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/rpc Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-node Major
@effect/sql Major
@effect/ai Major
@effect/ai-anthropic Major
@effect/ai-openai Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql-drizzle Major
@effect/sql-kysely Major

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

@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Apr 10, 2025
@effect-bot effect-bot changed the base branch from main to next-minor April 10, 2025 20:14
@effect-bot effect-bot force-pushed the next-minor branch 9 times, most recently from da4000d to 559a7b2 Compare April 12, 2025 08:09
@mikearnaldi
Copy link
Member

why not using plain Effect.timeout?

@effect-bot effect-bot force-pushed the next-minor branch 9 times, most recently from 0f8052f to 3e95392 Compare April 14, 2025 02:13
@thewilkybarkid
Copy link
Contributor Author

I'm looking to turn these into RequestErrors, which you can't (easily) with Effect.timeout*.

As mentioned in https://discord.com/channels/795981131316985866/1359836164005302392/1360164805025206322, composing the HttpClient with one that times out instead with an API like:

HttpClient.get('http://example.com/'),
HttpClient.withTimeout('1 second'),
Effect.andThen(...)

would work too.

@effect-bot effect-bot force-pushed the next-minor branch 3 times, most recently from c1b2504 to d73db84 Compare April 15, 2025 10:52
@effect-bot effect-bot force-pushed the next-minor branch 20 times, most recently from fa24b1a to 3b657fb Compare May 7, 2025 09:54
@effect-bot effect-bot force-pushed the next-minor branch 10 times, most recently from a6cebb8 to fa10f56 Compare May 11, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Discussion Ongoing
Development

Successfully merging this pull request may close these issues.

4 participants