-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary <!-- Succinctly describe your change, providing context, what you've changed, and why. --> The `onSendEvent.transformInput()` middleware hook is used to intercept events being sent and change either the shape or number of events being sent. When invoking a function via `step.invoke()`, an _internal_ `inngest/function.invoked` event is sent, though the `onSendEvent.transformInput()` hook is **not** currently run. For middleware like `@inngest/middleware-encryption`, this poses a challenge, as it can no longer encrypt fields when using `step.invoke()` instead of `step.sendEvent()`. This PR ensures that the hook is also used for events being sent via `step.invoke()`, such that middleware can now appropriately affect the payloads. Some notes on design decisions here: - The `onSendEvent` hook will be run for each individual `step.invoke()`. This is the same functionality as calling `step.sendEvent()` multiple times. While the `transformInput()` hook supports batched `payloads`, this makes it difficult to determine which payloads have been affected if a user has omitted some from the returned array. - Unlike `step.sendEvent()` or `inngest.send()`, we do not allow a developer to omit the event to be sent by `step.invoke()` ## 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" --> - [x] Added a [docs PR](https://github.com/inngest/website) that references this PR - [x] Added unit/integration tests - [x] Added changesets if applicable
- Loading branch information
1 parent
097ecc8
commit f6088e0
Showing
7 changed files
with
420 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"inngest": patch | ||
--- | ||
|
||
Fix `onSendEvent.transformInput()` middleware hooks not running for `step.invoke()` payloads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.