Skip to content

Commit

Permalink
fix: msg delay set multiple times doesn't cause error anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Siemon committed Oct 5, 2023
1 parent 7265c22 commit 346e20f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/module/sqs/prepare-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const prepareMessage = (msg, opts) => {
enumerable: false
});
}
if (opts.delaySeconds !== undefined) {
if (opts.delaySeconds !== undefined && !(DELAY_SECONDS in msg)) {
Object.defineProperty(msg, DELAY_SECONDS, {
value: opts.delaySeconds,
writable: false,
Expand Down
6 changes: 3 additions & 3 deletions test/module/sqs/queue-processor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ describe('Testing QueueProcessor', {

it('Testing multi prepare message error', async ({ capture }) => {
const msg = { name: 'step1' };
aws.sqs.prepareMessage(msg, { delaySeconds: 10 });
expect(() => aws.sqs.prepareMessage(msg, { delaySeconds: 20 }))
.to.throw('Cannot redefine property: Symbol(delay-seconds)');
aws.sqs.prepareMessage(msg, { urgent: false });
expect(() => aws.sqs.prepareMessage(msg, { urgent: true }))
.to.throw('Cannot redefine property: Symbol(urgent)');
});

it('Testing empty setting on message', async () => {
Expand Down

0 comments on commit 346e20f

Please sign in to comment.