Skip to content

Conversation

@aleclarson
Copy link
Member

@aleclarson aleclarson commented Jun 11, 2025

This PR is AI-generated.

Summary

This PR introduces a new queueByKey utility in the async module. It wraps an async function and ensures that calls with the same key are run one at a time, in order. Calls with different keys run in parallel.

This is helpful when you need to avoid race conditions for grouped operations—like:
• Serializing DB writes by record or table
• Avoiding overlapping API calls for the same user
• Throttling per group without blocking all calls globally

What’s included:
• Full TypeScript support with generics
• Clean error handling and propagation
• Automatic cleanup when queues are empty
• 100% test coverage
• Docs and usage examples

Related issue, if any:

N/A

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed (N/A - async functions don't require benchmarks per implementation guide)
  • Release notes in next-minor.md or next-major.md have been added, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1
A src/async/queueByKey.ts 215

Footnotes

  1. Function size includes the import dependencies of the function.

@aleclarson aleclarson moved this to In Progress in Radashi Jun 11, 2025
@aleclarson aleclarson added this to the v12.6.0 milestone Jun 11, 2025
@aleclarson aleclarson merged commit fb30703 into radashi-org:main Jun 26, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Released in Radashi Jun 26, 2025
@radashi-bot
Copy link

A stable release 12.6.0 has been published to NPM. 🚀

To install:

pnpm add radashi@12.6.0
See the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

2 participants