Skip to content
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

Set inngest's ALS in global state to access it across versions #819

Merged
merged 3 commits into from
Jan 27, 2025

Conversation

jpwilliams
Copy link
Member

@jpwilliams jpwilliams commented Jan 27, 2025

Summary

Moves inngest's AsyncLocalStorage usage to global state, ensuring we can access inngest context while using multiple versions and across boundaries.

Checklist

  • Added a docs PR that references this PR N/A KTLO
  • Added unit/integration tests N/A Included; multi-process tests not included - testing with @inngest/agent-kit
  • Added changesets if applicable

@jpwilliams jpwilliams added the ⬆️ improvement Performance, reliability, or usability improvements label Jan 27, 2025
@jpwilliams jpwilliams self-assigned this Jan 27, 2025
Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: 639b80d

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

This PR includes changesets to release 1 package
Name Type
inngest Patch

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

@inngest-release-bot inngest-release-bot added the 📦 inngest Affects the `inngest` package label Jan 27, 2025
@jpwilliams jpwilliams merged commit 7a5f4a5 into main Jan 27, 2025
52 checks passed
@jpwilliams jpwilliams deleted the fix/als-cross-package branch January 27, 2025 15:47
jpwilliams pushed a commit that referenced this pull request Jan 28, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Minor Changes

- [#820](#820)
[`cb02190`](cb02190)
Thanks [@amh4r](https://github.com/amh4r)! - Make
INNGEST_ALLOW_IN_BAND_SYNC opt out

- [#813](#813)
[`f42ab05`](f42ab05)
Thanks [@BrunoScheufler](https://github.com/BrunoScheufler)! - Add
initial `connect()` support

### Patch Changes

- [#818](#818)
[`c99b05f`](c99b05f)
Thanks [@BrunoScheufler](https://github.com/BrunoScheufler)! - Add
reconnection support to `connect()`

- [#819](#819)
[`7a5f4a5`](7a5f4a5)
Thanks [@jpwilliams](https://github.com/jpwilliams)! - Set `inngest`'s
ALS in global state to be able access it across versions and package
boundaries

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
jpwilliams added a commit that referenced this pull request Jan 30, 2025
## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

Adds `Inngest.Like` and `InngestFunction.Like` for lighter type
comparisons when comparing types across two different versions of
`inngest`.

This targets loosening types at two major boundaries:

- `serve()`, which receives an `Inngest` client and an array of
`InngestFunction`s
  - This also includes the `fastifyPlugin` we provide
- `connect()`, which receives an array of `InngestFunction`s

These boundaries only accepted `Inngest.Any` and `InngestFunction.Any`
types, which are bound to their local package version. This change
switches to duck typing for these boundaries, meaning a client from one
version can be safely used as the client for another.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~Added a [docs PR](https://github.com/inngest/website) that
references this PR~ N/A KTLO
- [ ] ~Added unit/integration tests~ N/A Existing
- [x] Added changesets if applicable

## Related
<!-- A space for any related links, issues, or PRs. -->
<!-- Linear issues are autolinked. -->
<!-- e.g. - INN-123 -->
<!-- GitHub issues/PRs can be linked using shorthand. -->
<!-- e.g. "- inngest/inngest#123" -->
<!-- Feel free to remove this section if there are no applicable related
links.-->
- Complements #819 for better multi-version handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬆️ improvement Performance, reliability, or usability improvements 📦 inngest Affects the `inngest` package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants