Skip to content

fix(sio): isolate recovery offsets across child namespaces - #5561

Open
xingsy97 wants to merge 2 commits into
socketio:mainfrom
xingsy97:fix/parent-namespace-recovery
Open

xingsy97 wants to merge 2 commits into
socketio:mainfrom
xingsy97:fix/parent-namespace-recovery

Conversation

@xingsy97

@xingsy97 xingsy97 commented Sep 22, 2026 •

Copy link
Copy Markdown

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

With connection state recovery enabled, room-targeted parent broadcasts pass the same packet to every child adapter. Each child appends its recovery offset to the shared data array, also modifying events already cached by earlier children. A replayed event can therefore carry another child's offset, causing a subsequent session recovery to fail.

New behavior

Shallow-copy the packet and its data array for each child adapter. Recovery offsets remain isolated, while nested payload objects and Buffers retain their original references.

@darrachequesne

Copy link
Copy Markdown
Member

Hi! Thanks for the pull request.

I wonder if it wouldn't be better to fix this in the addOffsetIfNecessary method here:

if (isEventPacket && withoutAcknowledgement && notVolatile) {
packet.data.push(offset);
}

This way, a new array will be created only if connection state recovery is enabled.

What do you think?

@xingsy97

xingsy97 commented Sep 28, 2026 •

Copy link
Copy Markdown
Author

Hi! Thanks for the pull request.

I wonder if it wouldn't be better to fix this in the addOffsetIfNecessary method here:

if (isEventPacket && withoutAcknowledgement && notVolatile) {
packet.data.push(offset);
}

This way, a new array will be created only if connection state recovery is enabled.

What do you think?

Agreed, I updated accordingly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants