-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨Collaboration long polling fallback #517
Open
AntoLC
wants to merge
7
commits into
main
Choose a base branch
from
feature/collab-long-polling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
520c7a4
🔧(y-provider) add missing Sentry environment
AntoLC 49721bc
✨(y-provider) collaboration polling
AntoLC 4e17d44
🚚(frontend) move toBase64
AntoLC 5544317
✨(frontend) create class CollaborationProvider
AntoLC 1584c08
🔧(ngnix) adapt nginx development
AntoLC b7c6833
🔧(helm) adapt helm nginx
AntoLC 56f9a00
for-testing
AntoLC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ on: | |
push: | ||
branches: | ||
- 'main' | ||
- 'feature/collab-long-polling' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
docker/files/etc/nginx/conf.d/00-collaboration-proxy-cache.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
proxy_cache_path /tmp/auth_cache levels=1:2 keys_zone=auth_cache:10m inactive=60s max_size=100m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/frontend/apps/e2e/__tests__/app-impress/doc-collaboration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
import { createDoc, verifyDocName } from './common'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/'); | ||
}); | ||
|
||
test.describe('Doc Collaboration', () => { | ||
/** | ||
* We check: | ||
* - connection to the collaborative server | ||
* - signal of the backend to the collaborative server (connection should close) | ||
* - reconnection to the collaborative server | ||
*/ | ||
test('checks the connection with collaborative server', async ({ | ||
page, | ||
browserName, | ||
}) => { | ||
let webSocketPromise = page.waitForEvent('websocket', (webSocket) => { | ||
return webSocket | ||
.url() | ||
.includes('ws://localhost:8083/collaboration/ws/?room='); | ||
}); | ||
|
||
const [title] = await createDoc(page, 'doc-editor', browserName, 1); | ||
await verifyDocName(page, title); | ||
|
||
let webSocket = await webSocketPromise; | ||
expect(webSocket.url()).toContain( | ||
'ws://localhost:8083/collaboration/ws/?room=', | ||
); | ||
|
||
// Is connected | ||
let framesentPromise = webSocket.waitForEvent('framesent'); | ||
|
||
await page.locator('.ProseMirror.bn-editor').click(); | ||
await page.locator('.ProseMirror.bn-editor').fill('Hello World'); | ||
|
||
let framesent = await framesentPromise; | ||
expect(framesent.payload).not.toBeNull(); | ||
|
||
await page.getByRole('button', { name: 'Share' }).click(); | ||
|
||
const selectVisibility = page.getByLabel('Visibility', { exact: true }); | ||
|
||
// When the visibility is changed, the ws should closed the connection (backend signal) | ||
const wsClosePromise = webSocket.waitForEvent('close'); | ||
|
||
await selectVisibility.click(); | ||
await page | ||
.getByRole('button', { | ||
name: 'Connected', | ||
}) | ||
.click(); | ||
|
||
// Assert that the doc reconnects to the ws | ||
const wsClose = await wsClosePromise; | ||
expect(wsClose.isClosed()).toBeTruthy(); | ||
|
||
// Checkt the ws is connected again | ||
webSocketPromise = page.waitForEvent('websocket', (webSocket) => { | ||
return webSocket | ||
.url() | ||
.includes('ws://localhost:8083/collaboration/ws/?room='); | ||
}); | ||
|
||
webSocket = await webSocketPromise; | ||
framesentPromise = webSocket.waitForEvent('framesent'); | ||
framesent = await framesentPromise; | ||
expect(framesent.payload).not.toBeNull(); | ||
}); | ||
|
||
test('checks the connection switch to polling after websocket failure', async ({ | ||
page, | ||
browserName, | ||
}) => { | ||
const responsePromise = page.waitForResponse( | ||
(response) => | ||
response.url().includes('/poll/') && response.status() === 200, | ||
); | ||
|
||
await page.routeWebSocket( | ||
'ws://localhost:8083/collaboration/ws/**', | ||
async (ws) => { | ||
await ws.close(); | ||
}, | ||
); | ||
|
||
await page.reload(); | ||
|
||
await createDoc(page, 'doc-polling', browserName, 1); | ||
|
||
const response = await responsePromise; | ||
expect(response.ok()).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/frontend/apps/impress/src/features/docs/doc-management/api/collaborationRequests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { APIError, errorCauses } from '@/api'; | ||
|
||
interface PollOutgoingMessageParams { | ||
pollUrl: string; | ||
message64: string; | ||
} | ||
interface PollOutgoingMessageResponse { | ||
updated?: boolean; | ||
} | ||
|
||
export const pollOutgoingMessageRequest = async ({ | ||
pollUrl, | ||
message64, | ||
}: PollOutgoingMessageParams): Promise<PollOutgoingMessageResponse> => { | ||
const response = await fetch(pollUrl, { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
message64, | ||
}), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new APIError( | ||
`Post poll message request failed`, | ||
await errorCauses(response), | ||
); | ||
} | ||
|
||
return response.json() as Promise<PollOutgoingMessageResponse>; | ||
}; | ||
|
||
interface PollSyncParams { | ||
pollUrl: string; | ||
localDoc64: string; | ||
} | ||
interface PollSyncResponse { | ||
syncDoc64?: string; | ||
} | ||
|
||
export const postPollSyncRequest = async ({ | ||
pollUrl, | ||
localDoc64, | ||
}: PollSyncParams): Promise<PollSyncResponse> => { | ||
const response = await fetch(pollUrl, { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
localDoc64, | ||
}), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new APIError( | ||
`Sync request failed: ${response.status} ${response.statusText}`, | ||
await errorCauses(response), | ||
); | ||
} | ||
|
||
return response.json() as Promise<PollSyncResponse>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add something more specific to avoid sharing the same cache key later with an other location