Skip to content

Commit

Permalink
Merge pull request #4 from ankit-kumar-jat/on-messgae-prefix-check
Browse files Browse the repository at this point in the history
fix: add prefix check to prevent unwanted error message
  • Loading branch information
nfriedly authored May 29, 2024
2 parents 5cde0bf + b712f1c commit f41cb77
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/primary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class ClusterMemoryStorePrimary {
requestId,
result,
from,
prefix,
}
debug('Sending response to worker %d: %o', worker.id, message)
worker.send(message)
Expand Down
2 changes: 1 addition & 1 deletion source/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export type Command = keyof Omit<Store, 'prefix' | 'localKeys'>

type Message = {
from: 'cluster-memory-store'
prefix: string
}

export type WorkerToPrimaryMessage = Message & {
command: Command
args: any[]
requestId: number
prefix: string
}

export type PrimaryToWorkerMessage = Message & {
Expand Down
2 changes: 1 addition & 1 deletion source/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class ClusterMemoryStoreWorker implements Store {

private onMessage(message: any) {
debug('Recieved message %o', message)
if (message?.from === from) {
if (message?.from === from && message?.prefix === this.prefix) {
const message_ = message as PrimaryToWorkerMessage
if (this.openRequests.has(message_.requestId)) {
const { timeoutId, resolve } = this.openRequests.get(
Expand Down

0 comments on commit f41cb77

Please sign in to comment.