Skip to content

Commit 541faed

Browse files
committed
Add handling for corrupted messages
1 parent 5fec80a commit 541faed

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strontium",
3-
"version": "2.4.14",
3+
"version": "2.4.15",
44
"description": "Strontium is a TypeScript toolkit for High Performance API servers built for Production not Projects.",
55
"main": "lib/src/index.js",
66
"types": "lib/src/index.d.ts",

src/queue/drivers/gcps/GCPSConsumer.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,26 @@ export class GCPSConsumer implements Process {
9393
)
9494

9595
await Promise.all(
96-
messages.map(
97-
async (m) =>
98-
await this.executeTask(
99-
m.ackId,
100-
{
101-
eventName:
102-
m.message.attributes.STRONTIUM_EVENT_NAME,
103-
message: m.message.data,
104-
},
105-
container
96+
messages.map(async (m) => {
97+
if (m.message.attributes === undefined) {
98+
if (this.logger) {
99+
this.logger.info(
100+
`[GCPS - TASK - START] Event discarded due to corrupted attributes.`
106101
)
107-
)
102+
}
103+
104+
return this.ack(m.ackId)
105+
}
106+
107+
return this.executeTask(
108+
m.ackId,
109+
{
110+
eventName: m.message.attributes.STRONTIUM_EVENT_NAME,
111+
message: m.message.data,
112+
},
113+
container
114+
)
115+
})
108116
)
109117
}
110118
}

0 commit comments

Comments
 (0)