Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/handler/PadMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const handlePadDelete = async (socket: any, padDeleteMessage: PadDeleteMessage)
// Only the one doing the first revision can delete the pad, otherwise people could troll a lot
const firstContributor = await retrievedPad.getRevisionAuthor(0)
if (session.author === firstContributor) {
retrievedPad.remove()
await retrievedPad.remove()
} else {

type ShoutMessage = {
Expand Down
11 changes: 9 additions & 2 deletions src/static/js/pad_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ const padeditor = (() => {
// delete pad
$('#delete-pad').on('click', () => {
if (window.confirm(html10n.get('pad.delete.confirm'))) {
// Wait for the server to confirm deletion before navigating away.
// Navigating immediately caused a race condition where the browser
// (especially Firefox) would close the WebSocket before the delete
// message reached the server. See #7306.
pad.socket.on('message', (data: any) => {
if (data && data.disconnect === 'deleted') {
window.location.href = '/';
}
});
pad.collabClient.sendMessage({type: 'PAD_DELETE', data:{padId: pad.getPadId()}});
// redirect to home page after deletion
window.location.href = '/';
}
Comment on lines +89 to 99
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Missing pad_delete regression test 📘 Rule violation ⚙ Maintainability

This PR changes pad deletion behavior on both the client and server but does not include an
automated regression test that would fail if the fix were reverted. Without test coverage, the
delete race condition (and related redirect behavior) can be reintroduced unnoticed.
Agent Prompt
## Issue description
The Delete Pad bug fix is not accompanied by a regression test, so the race-condition/redirect behavior can regress without being caught by CI.

## Issue Context
This PR changes the client to wait for `{disconnect: 'deleted'}` before navigating and changes the server to `await` pad removal. Add a deterministic automated test that fails if these changes are reverted.

## Fix Focus Areas
- src/tests/backend/specs/messages.ts[57-258]
- src/tests/backend/common.ts[254-264]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

})

Expand Down
Loading