n8n/packages/cli/test/unit
Iván Ovejero 22a5f5258d
feat(core): Cache test webhook registrations (#8176)
In a multi-main setup, we have the following issue. The user's client
connects to main A and runs a test webhook, so main A starts listening
for a webhook call. A third-party service sends a request to the test
webhook URL. The request is forwarded by the load balancer to main B,
who is not listening for this webhook call. Therefore, the webhook call
is unhandled.

To start addressing this, cache test webhook registrations, using Redis
for queue mode and in-memory for regular mode. When the third-party
service sends a request to the test webhook URL, the request is
forwarded by the load balancer to main B, who fetches test webhooks from
the cache and, if it finds a match, executes the test webhook. This
should be transparent - test webhook behavior should remain the same as
so far.

Notes:
- Test webhook timeouts are not cached. A timeout is only relevant to
the process it was created in, so another process retrieving from Redis
a "foreign" timeout will be unable to act on it. A timeout also has
circular references, so `cache-manager-ioredis-yet` is unable to
serialize it.
- In a single-main scenario, the timeout remains in the single process
and is cleared on test webhook expiration, successful execution, and
manual cancellation - all as usual.
- In a multi-main scenario, we will need to have the process who
received the webhook call send a message to the process who created the
webhook directing this originating process to clear the timeout. This
will likely be implemented via execution lifecycle hooks and Redis
channel messages checking session ID. This implementation is out of
scope for this PR and will come next.
- Additional data in test webhooks is not cached. From what I can tell,
additional data is not needed for test webhooks to be executed.
Additional data also has circular references, so
`cache-manager-ioredis-yet` is unable to serialize it.

Follow-up to: #8155
2024-01-03 16:58:33 +01:00
..
collaboration refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8186) 2024-01-02 17:53:24 +01:00
controllers refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8186) 2024-01-02 17:53:24 +01:00
databases/utils fix(editor): Validate user info before submiting (#7608) 2023-11-22 12:14:44 +01:00
decorators feat(core): Unify application components shutdown (#8097) 2023-12-22 12:39:58 +02:00
execution-lifecyle fix: Stop binary data restoration from preventing execution from finishing (#8082) 2023-12-21 09:40:39 +00:00
ExternalSecrets ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
license refactor(core): Move license endpoints to a decorated controller class (no-changelog) (#8074) 2023-12-19 12:13:19 +01:00
middleware refactor(core): Make Logger a service (no-changelog) (#7494) 2023-10-25 16:35:22 +02:00
push ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
repositories refactor(core): Move typeorm operators from WaitTracker to ExecutionRepository (no-changelog) (#8163) 2023-12-28 19:22:09 +01:00
services feat(core): Cache test webhook registrations (#8176) 2024-01-03 16:58:33 +01:00
shared fix(core): Prevent workflow history saving error from happening (#7812) 2023-12-13 11:41:06 +00:00
shutdown feat(core): Unify application components shutdown (#8097) 2023-12-22 12:39:58 +02:00
utilities refactor(core): Introduce password utility (no-changelog) (#7979) 2023-12-11 18:23:42 +01:00
ActiveExecutions.test.ts refactor(core): Don't use DB transactions on ExecutionRepository.createNewExecution (#8002) 2023-12-12 14:36:56 +01:00
CredentialsHelper.test.ts refactor(core): Delete unused code, and fix typings in tests (no-changelog) (#8142) 2023-12-22 15:41:29 +01:00
CredentialTypes.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
CurlConverterHelper.test.ts ci: Expand ESLint to tests in BE packages (no-changelog) (#6147) 2023-05-02 10:37:19 +02:00
Helpers.ts ci: Expand ESLint to tests in BE packages (no-changelog) (#6147) 2023-05-02 10:37:19 +02:00
InternalHooks.test.ts refactor(core): Delete unused code, and fix typings in tests (no-changelog) (#8142) 2023-12-22 15:41:29 +01:00
License.test.ts refactor(core): Move license endpoints to a decorated controller class (no-changelog) (#8074) 2023-12-19 12:13:19 +01:00
PermissionChecker.test.ts test(core): Improve tests for subworkflow caller policy checks (no-changelog) (#7954) 2023-12-08 11:21:43 +01:00
PostHog.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
SourceControl.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
Telemetry.test.ts refactor(core): Delete unused code, and fix typings in tests (no-changelog) (#8142) 2023-12-22 15:41:29 +01:00
TestWebhooks.test.ts feat(core): Cache test webhook registrations (#8176) 2024-01-03 16:58:33 +01:00
UserManagementMailer.test.ts fix(core): Do not return inviteAcceptUrl in response if email was sent (#7465) 2023-10-19 13:58:06 +02:00
utils.test.ts refactor(core): Improve test-webhooks (no-changelog) (#8069) 2023-12-19 17:32:02 +01:00
WebhookHelpers.test.ts feat(core): Add Support for custom CORS origins for webhooks (#7455) 2023-11-22 17:49:56 +01:00
webhooks.test.ts refactor(core): Extract ActiveWebhooks out of ActiveWorkflowRunner (no-changelog) (#8171) 2023-12-28 10:04:32 +01:00
WorkflowExecuteAdditionalData.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
WorkflowHelpers.test.ts fix(core): Prevent workflow history saving error from happening (#7812) 2023-12-13 11:41:06 +00:00
workflowHistoryHelper.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00
WorkflowRunner.test.ts ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671) 2023-11-10 15:04:26 +01:00