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` 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 } ) }) })