Skip to content

Commit

Permalink
Do not emit 'migrate' event unless it's the migrate response
Browse files Browse the repository at this point in the history
  • Loading branch information
mdingena committed Apr 5, 2024
1 parent 80440d8 commit ce90491
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Subscriptions/Subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ export class Subscriptions {

const message = JSON.parse(data.toString());

/* Handle messages during migration. */
if (migrationId === that.migrationId && typeof that.resolveHalted !== 'undefined') {
that.events.emit('migrate', message);
return;
}

if (typeof message.content === 'undefined') {
that.client.logger.error(
`Received a message with ID ${that.instanceId}-${message.id} but no content.`,
Expand All @@ -136,6 +130,16 @@ export class Subscriptions {
return;
}

/* Handle messages during migration. */
if (
migrationId === that.migrationId &&
typeof that.resolveHalted !== 'undefined' &&
message.key === 'POST /ws/migrate'
) {
that.events.emit('migrate', message);
return;
}

that.client.logger.debug(
`Received ${message.event} message with ID ${that.instanceId}-${message.id}.`,
JSON.stringify(message)
Expand Down

0 comments on commit ce90491

Please sign in to comment.