From d0cc1f9a27e631a7a85647a23590324a71ad7327 Mon Sep 17 00:00:00 2001 From: Alex Luckett Date: Wed, 6 Aug 2025 21:51:53 +0100 Subject: [PATCH 1/2] Set timeout for page events to 5 seconds --- src/server/plugins/engine/routes/questions.ts | 2 +- test/form/plugin-options.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/plugins/engine/routes/questions.ts b/src/server/plugins/engine/routes/questions.ts index 09e5d2972..e69c3e2d6 100644 --- a/src/server/plugins/engine/routes/questions.ts +++ b/src/server/plugins/engine/routes/questions.ts @@ -63,7 +63,7 @@ async function handleHttpEvent( // @ts-expect-error - function signature will be refactored in the next iteration of the formatter const payload = format(context, items, model, undefined, undefined) - const opts = { payload } + const opts: httpService.RequestOptions = { payload, timeout: 5000 } if (preparePageEventRequestOptions) { preparePageEventRequestOptions(opts, event, page, context) diff --git a/test/form/plugin-options.test.js b/test/form/plugin-options.test.js index 001e49468..9ef241922 100644 --- a/test/form/plugin-options.test.js +++ b/test/form/plugin-options.test.js @@ -51,7 +51,7 @@ describe('Plugin options - page events', () => { expect(httpService.postJson).toHaveBeenCalledExactlyOnceWith( 'http://example.com', - { payload: expect.any(String) } + { payload: expect.any(String), timeout: 5000 } ) }) }) @@ -97,7 +97,7 @@ describe('Plugin options - page events with preparePageEventRequestOptions', () }) expect(preparePageEventRequestOptions).toHaveBeenCalledExactlyOnceWith( - { payload: expect.any(String) }, + { payload: expect.any(String), timeout: 5000 }, { type: 'http', options: { @@ -111,7 +111,7 @@ describe('Plugin options - page events with preparePageEventRequestOptions', () expect(httpService.postJson).toHaveBeenCalledExactlyOnceWith( 'http://example.com', - { payload: expect.any(String) } + { payload: expect.any(String), timeout: 5000 } ) }) }) From 8098e15a0ff983fd13f009e798d2fb518ced9671 Mon Sep 17 00:00:00 2001 From: David Stone Date: Mon, 30 Mar 2026 10:08:36 +0100 Subject: [PATCH 2/2] Update docs --- docs/features/configuration-based/page-events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/features/configuration-based/page-events.md b/docs/features/configuration-based/page-events.md index 5782f2fda..5b355cf0f 100644 --- a/docs/features/configuration-based/page-events.md +++ b/docs/features/configuration-based/page-events.md @@ -44,7 +44,7 @@ Currently supported event types: ### Supported actions -- `http`: Makes a HTTP(S) call to a web service. This service must be routable (e.g. by configuring CDP's squid proxy), must accept forms-engine-plugin's standardised payload, return HTTP 200 and a valid JSON document. +- `http`: Makes a HTTP(S) call to a web service. This service must be routable (e.g. by configuring CDP's squid proxy), must accept forms-engine-plugin's standardised payload, return HTTP 200 and a valid JSON document. **A timeout of 5 seconds is set on each HTTP event.** - Options: - `method`: The HTTP method, e.g. `POST` or `GET`. Note that forms-engine-plugin posts the form state as a payload, so `POST` is the correct method if you need to parse the form data. - `url`: A fully formed HTTP(S) URL, e.g. `https://my-api.defra.gov.uk` or `https://my-api.prod.cdp-int.defra.cloud`