Skip to content

Commit

Permalink
Merge pull request #4297 from nextcloud/bugfix/noid/sync-after-push-r…
Browse files Browse the repository at this point in the history
…econnect
  • Loading branch information
juliushaertl committed Jun 21, 2023
2 parents a673891 + 72dfc69 commit a6b5832
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 33 deletions.
30 changes: 15 additions & 15 deletions cypress/e2e/sync.spec.js
Expand Up @@ -66,26 +66,26 @@ describe('Sync', () => {

it('recovers from a lost connection', () => {
let count = 0
cy.intercept({ method: 'POST', url: '**/apps/text/session/push' }, (req) => {
if (count < 5) {
count++
cy.intercept({ method: 'POST', url: '**/apps/text/session/*' }, (req) => {
if (count < 4) {
req.destroy()
req.alias = 'dead'
} else {
req.alias = 'alive'
}
}).as('push')
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }, (req) => {
if (count < 5) {
count++
req.destroy()
req.alias = 'deadSync'
}
})
cy.get('#editor-container .document-status')
.should('contain', 'File could not be loaded', { timeout: 10000 })
cy.get('#editor-container .document-status', { timeout: 30000 })
.should('not.contain', 'File could not be loaded')
}).as('sessionRequests')
cy.wait('@dead', { timeout: 30000 })
cy.get('#editor-container .document-status', { timeout: 10000 })
.should('contain', 'File could not be loaded')
.then(() => {
count = 4
})
cy.wait('@alive', { timeout: 30000 })
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' })
.as('syncAfterRecovery')
cy.wait('@syncAfterRecovery', { timeout: 30000 })
cy.get('#editor-container .document-status', { timeout: 30000 })
.should('not.contain', 'File could not be loaded')
cy.getContent().type('* more content added after the lost connection{enter}')
cy.wait('@syncAfterRecovery')
cy.closeFile()
Expand Down
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/services/SyncService.js
Expand Up @@ -161,6 +161,11 @@ class SyncService {
return this.connection.push(data)
.then((response) => {
this.sending = false
this.emit('sync', {
steps: [],
document: this.connection.document,
version: this.version,
})
}).catch(({ response, code }) => {
logger.error('failed to apply steps due to collission, retrying')
this.sending = false
Expand Down

0 comments on commit a6b5832

Please sign in to comment.