diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-09-06 22:32:04 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-09-08 01:24:50 +0200 |
commit | 5f8f4e6484faff23821ca7c009e309382fba914d (patch) | |
tree | 6d399fb90b4aa3527c30c502ba474cd83b5c94b2 /subprojects/frontend/src/xtext/webSocketMachine.ts | |
parent | feat(frontend): handle page hide events (diff) | |
download | refinery-5f8f4e6484faff23821ca7c009e309382fba914d.tar.gz refinery-5f8f4e6484faff23821ca7c009e309382fba914d.tar.zst refinery-5f8f4e6484faff23821ca7c009e309382fba914d.zip |
feat(frontend): check for updates periodically
Diffstat (limited to 'subprojects/frontend/src/xtext/webSocketMachine.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/webSocketMachine.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/subprojects/frontend/src/xtext/webSocketMachine.ts b/subprojects/frontend/src/xtext/webSocketMachine.ts index 25689cec..a1eee781 100644 --- a/subprojects/frontend/src/xtext/webSocketMachine.ts +++ b/subprojects/frontend/src/xtext/webSocketMachine.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import ms from 'ms'; | ||
1 | import { actions, assign, createMachine, RaiseAction } from 'xstate'; | 2 | import { actions, assign, createMachine, RaiseAction } from 'xstate'; |
2 | 3 | ||
3 | const { raise } = actions; | 4 | const { raise } = actions; |
4 | 5 | ||
5 | const ERROR_WAIT_TIMES = [200, 1000, 5000, 30_000]; | 6 | const ERROR_WAIT_TIMES = ['200', '1s', '5s', '30s'].map(ms); |
6 | 7 | ||
7 | export interface WebSocketContext { | 8 | export interface WebSocketContext { |
8 | webSocketURL: string | undefined; | 9 | webSocketURL: string | undefined; |
@@ -229,9 +230,9 @@ export default createMachine( | |||
229 | needsNetwork: ({ webSocketURL }) => !isWebSocketURLLocal(webSocketURL), | 230 | needsNetwork: ({ webSocketURL }) => !isWebSocketURLLocal(webSocketURL), |
230 | }, | 231 | }, |
231 | delays: { | 232 | delays: { |
232 | IDLE_TIMEOUT: 300_000, | 233 | IDLE_TIMEOUT: ms('5m'), |
233 | OPEN_TIMEOUT: 10_000, | 234 | OPEN_TIMEOUT: ms('10s'), |
234 | PING_PERIOD: 10_000, | 235 | PING_PERIOD: ms('10s'), |
235 | ERROR_WAIT_TIME: ({ errors: { length: retryCount } }) => { | 236 | ERROR_WAIT_TIME: ({ errors: { length: retryCount } }) => { |
236 | const { length } = ERROR_WAIT_TIMES; | 237 | const { length } = ERROR_WAIT_TIMES; |
237 | const index = retryCount < length ? retryCount : length - 1; | 238 | const index = retryCount < length ? retryCount : length - 1; |