n8n/packages/cli/test
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
..
integration fix(core): Better input validation for the changeRole endpoint (#8189) 2024-01-03 09:33:35 +01:00
shared refactor(core): Use Dependency Injection for all Controller classes (no-changelog) (#8146) 2023-12-27 11:50:43 +01:00
unit feat(core): Cache test webhook registrations (#8176) 2024-01-03 16:58:33 +01:00
extend-expect.ts feat(core): Security audit (#5034) 2023-01-05 13:28:40 +01:00
setup-mocks.ts fix(core): Do not allow arbitrary path traversal in the credential-translation endpoint (#5522) 2023-02-21 11:21:04 +01:00
setup-test-folder.ts refactor(core): Abstract away InstanceSettings and encryptionKey into injectable services (no-changelog) (#7471) 2023-10-23 13:39:35 +02:00
setup.ts ci: Block all external network calls in tests (no-changelog) (#4930) 2022-12-14 15:28:41 +01:00
teardown.ts ci: Fix test database cleanup (no-changelog) (#6188) 2023-05-05 12:12:37 +02:00