Skip to content

Conversation

@clemyan
Copy link
Member

@clemyan clemyan commented Oct 14, 2025

What's the problem this PR addresses?

There are a number of configurations that represent a duration of time (e.g. httpTimeout). Currently those use the NUMBER settings type with a predefined unit (e.g. milliseconds for httpTimeout). But:

  1. Each setting uses a different unit so users need to context switch to the docs to read/write those config
  2. Because YAML doesn't support arithmetic expressions, unit conversions need to be done beforehand in order to properly set those settings.

How did you fix it?

Create a new DURATION settings type that allows specifying the duration as a string in the following format:

  1. An integer or decimal value
  2. Optionally a unit among ms, s, m, h, d, w

For backward compatibility, a DURATION is parsed to a number using the existing predefined unit for that setting. That unit is also used if one is not specified.

I have only implemented units that the exactly convertible to each other* to avoid something like having to convert 1 month to an exact number of days.

(* not entirely true since 1 day is not always 24 hours)

In the future, maybe we can use a proper duration data structure to do proper date calculations. (So that, for example, setting a DURATION to 1 month actually means "1 calendar month" instead of an approximate number of seconds)

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@clemyan clemyan changed the title Core: Create DURATION settings type core: Create DURATION settings type Oct 21, 2025
@clemyan clemyan changed the title core: Create DURATION settings type Core: Create DURATION settings type Oct 21, 2025
@arcanis arcanis merged commit b9ccd93 into master Nov 7, 2025
25 of 26 checks passed
@arcanis arcanis deleted the clemyan/settings-type-duration branch November 7, 2025 10:09
@G4GURGAA

This comment has been minimized.

Gudahtt added a commit to Gudahtt/berry that referenced this pull request Feb 9, 2026
…lowlist

* origin/master: (212 commits)
  CI: Select node version to run CI against automatically (yarnpkg#7032)
  Fixes foreach order when --topological isnt set (yarnpkg#6997)
  fix(fslib): handle float timestamps in convertToBigIntStats (yarnpkg#6988)
  Fixes the `/<name>/<version>` format (yarnpkg#6993)
  docs(constraints): add missing @typedef alias for `Context` (yarnpkg#6989)
  Sync master with the changes from master
  Releasing 3 new packages
  Fix JSON Schema (yarnpkg#6973)
  Implements npm web login support (yarnpkg#6981)
  fix(git): split `-c` and `core.autocrlf=false` into separate args for `clone` (yarnpkg#6983)
  Sync master with the changes from master
  Releasing 8 new packages
  Allow catalogs to work with descriptors without resolvers (yarnpkg#6930)
  docs: Clarify additional use-case of npmMinimalAgeGate (yarnpkg#6945)
  Migrates the "typescript" dependencies to a catalog (yarnpkg#6969)
  Support escaping template variables in environment values (yarnpkg#6935)
  Core: Create DURATION settings type (yarnpkg#6942)
  fix: use correct env var to detect gitlab CI for OIDC (yarnpkg#6938)
  Update README.md badge link (yarnpkg#6947)
  fix(publish): use correct workspace name in --json output (yarnpkg#6949)
  ...
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