Skip to content

Commit

Permalink
fix(editor): Don't reconnect Editor on connection issues
Browse files Browse the repository at this point in the history
SyncService will resend failed steps after network has recovered.

Remove obsolete `data.retry` flag when emitting error of
`ERROR_TYPE.CONNECTION_FAILED`.

Fixes: #4340

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Jul 11, 2023
1 parent 29bd1f8 commit fee8224
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,7 @@ export default {
}
if (type === ERROR_TYPE.CONNECTION_FAILED && !this.hasConnectionIssue) {
this.hasConnectionIssue = true
// FIXME: ideally we just try to reconnect in the service, so we don't loose steps
OC.Notification.showTemporary('Connection failed, reconnecting')
if (data.retry !== false) {
setTimeout(this.reconnect.bind(this), 5000)
}
OC.Notification.showTemporary('Connection failed.')
}
if (type === ERROR_TYPE.SOURCE_NOT_FOUND) {
this.hasConnectionIssue = true
Expand Down
6 changes: 3 additions & 3 deletions src/services/PollingBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class PollingBackend {
if (!e.response || e.code === 'ECONNABORTED') {
if (this.#fetchRetryCounter++ >= MAX_RETRY_FETCH_COUNT) {
logger.error('[PollingBackend:fetchSteps] Network error when fetching steps, emitting CONNECTION_FAILED')
this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: { retry: false } })
this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: {} })

} else {
logger.error(`[PollingBackend:fetchSteps] Network error when fetching steps, retry ${this.#fetchRetryCounter}`)
Expand All @@ -180,11 +180,11 @@ class PollingBackend {
this.disconnect()
} else if (e.response.status === 503) {
this.increaseRefetchTimer()
this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: { retry: false } })
this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: {} })
logger.error('Failed to fetch steps due to unavailable service', { error: e })
} else {
this.disconnect()
this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: { retry: false } })
this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: {} })
logger.error('Failed to fetch steps due to other reason', { error: e })
}

Expand Down

0 comments on commit fee8224

Please sign in to comment.