upstash / qstash-js

Message queue for serverless
https://docs.upstash.com/qstash
MIT License
164 stars 18 forks source link

Type specification error for type PublishRequest<TBody = BodyInit>['contentBasedDeduplication'] #204

Closed GiovaniMFMurari closed 6 days ago

GiovaniMFMurari commented 1 week ago

Hi,

We have noticed a strange behaviour when trying to avoid deduplication on message publishing, for a specific use-case.

The type specification describes the property contentBasedDeduplication of the messaging publishing requests, given by the type PublishRequest as a boolean with default false. But when parsing the js request object properties to the Qstash HTTP request headers it sets the value to "true" whenever the value in contentBasedDeduplication is not undefined. So when passing contentBasedDeduplication as false, it stills set the header value to true, deduplicating the message anyway. (See: https://github.com/upstash/qstash-js/blob/main/src/client/utils.ts#L50)

IMO although an easy workaround would be passing undefined, or not passing the value at all, it should set the value to what the user passes, accordingly to the type specification.

CahidArda commented 1 week ago

Hi there,

There seems to be an issue in how we set the Upstash-Content-Based-Deduplication header like you said.

We will fix it to work like this:

if (request.contentBasedDeduplication) {
  headers.set("Upstash-Content-Based-Deduplication", "true");
}