Skip to content

Commit 9abafcf

Browse files
Set timeout for page events to 5 seconds (#152)
* Set timeout for page events to 5 seconds * Update docs --------- Co-authored-by: David Stone <davidjamesstone@gmail.com>
1 parent 690877b commit 9abafcf

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

docs/features/configuration-based/page-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Currently supported event types:
4444

4545
### Supported actions
4646

47-
- `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.
47+
- `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.**
4848
- Options:
4949
- `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.
5050
- `url`: A fully formed HTTP(S) URL, e.g. `https://my-api.defra.gov.uk` or `https://my-api.prod.cdp-int.defra.cloud`

src/server/plugins/engine/routes/questions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function handleHttpEvent(
6363

6464
// @ts-expect-error - function signature will be refactored in the next iteration of the formatter
6565
const payload = format(context, items, model, undefined, undefined)
66-
const opts = { payload }
66+
const opts: httpService.RequestOptions = { payload, timeout: 5000 }
6767

6868
if (preparePageEventRequestOptions) {
6969
preparePageEventRequestOptions(opts, event, page, context)

test/form/plugin-options.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('Plugin options - page events', () => {
5151

5252
expect(httpService.postJson).toHaveBeenCalledExactlyOnceWith(
5353
'http://example.com',
54-
{ payload: expect.any(String) }
54+
{ payload: expect.any(String), timeout: 5000 }
5555
)
5656
})
5757
})
@@ -97,7 +97,7 @@ describe('Plugin options - page events with preparePageEventRequestOptions', ()
9797
})
9898

9999
expect(preparePageEventRequestOptions).toHaveBeenCalledExactlyOnceWith(
100-
{ payload: expect.any(String) },
100+
{ payload: expect.any(String), timeout: 5000 },
101101
{
102102
type: 'http',
103103
options: {
@@ -111,7 +111,7 @@ describe('Plugin options - page events with preparePageEventRequestOptions', ()
111111

112112
expect(httpService.postJson).toHaveBeenCalledExactlyOnceWith(
113113
'http://example.com',
114-
{ payload: expect.any(String) }
114+
{ payload: expect.any(String), timeout: 5000 }
115115
)
116116
})
117117
})

0 commit comments

Comments
 (0)