Skip to content

Conversation

@SebastiaanWouters
Copy link
Contributor

Summary

Addresses feedback from #2958 to simplify the ky client configuration by removing the namespace approach.

Changes

  • Remove kyOptions namespace - Config now directly extends ky.Options
  • Remove RetryOptions wrapper - Users now have access to all 10 ky retry properties instead of just 3
  • Use top-level imports - Changed from import('ky') to proper import type { KyInstance, Options } from 'ky'
  • Fix ky instance type - Changed ky?: typeof ky to ky?: KyInstance for proper custom instance support
  • Remove manual retry mapping - Retry options now pass through directly to ky

Benefits

  • Simpler: One configuration surface, no precedence questions
  • Full feature access: Users get all ky retry properties (jitter, backoffLimit, custom delay functions, shouldRetry callbacks)
  • Consistent: Matches axios/fetch client patterns
  • Better types: Proper support for custom ky instances via ky.create()
  • Docs compatible: Implementation now matches documentation examples

Before

client.setConfig({
  timeout: 5000,
  retry: { limit: 3 },  // Only 3 properties available
  kyOptions: {          // Namespace for "escape hatch"
    jitter: true,
    backoffLimit: 30000
  }
});

After

client.setConfig({
  timeout: 5000,
  retry: {              // Full ky retry API
    limit: 3,
    jitter: true,
    backoffLimit: 30000,
    delay: (attemptCount) => 0.3 * (2 ** (attemptCount - 1)) * 1000,
  }
});

Test Plan

  • ✅ All tests passing (835/835)
  • ✅ Build succeeds
  • ✅ Type checking passes

- Remove kyOptions namespace in favor of flat config extending ky.Options
- Remove custom RetryOptions wrapper to expose full ky retry API (10 properties)
- Change ky instance type from typeof ky to KyInstance for proper custom instance support
- Use top-level imports instead of inline import() for better readability
- Remove manual retry property mapping that limited functionality
- Align with axios/fetch client patterns for consistency

This gives users full access to ky's API including advanced retry features
like jitter, backoffLimit, custom delay functions, and shouldRetry callbacks.
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

⚠️ No Changeset found

Latest commit: a799dc3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 11, 2025

@SebastiaanWouters is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. client Client package related labels Nov 11, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Nov 11, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 11, 2025
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.38%. Comparing base (caf79e8) to head (a799dc3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2961      +/-   ##
==========================================
- Coverage   29.41%   29.38%   -0.04%     
==========================================
  Files         403      403              
  Lines       35766    35748      -18     
  Branches     2066     2063       -3     
==========================================
- Hits        10522    10504      -18     
  Misses      25217    25217              
  Partials       27       27              
Flag Coverage Δ
unittests 29.38% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/codegen-core@2961
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2961
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2961
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2961

commit: a799dc3

>,
CoreConfig {
/**
* Base URL for all requests made by this client.
Copy link
Member

Choose a reason for hiding this comment

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

@SebastiaanWouters Why remove these comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not a fan of many verbose comments, code should explain itself.

Copy link
Member

Choose a reason for hiding this comment

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

This is a user-facing interface, comments are a must, you don't want people to dig into code unless something goes wrong!

signal: opts.signal,
throwHttpErrors: opts.throwOnError ?? false,
timeout: opts.timeout,
...opts.kyOptions,
Copy link
Member

Choose a reason for hiding this comment

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

@SebastiaanWouters Will this still work since opts isn't being spread?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes all options are being plucked from the opts. opts.kyOptions is no longer a thing. However, the spreading can be moved to opts (for most props)

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Client package related size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants