fix: Refactor RoktManager with deferred call handling and message queue processing#1051
Conversation
src/roktManager.ts
Outdated
There was a problem hiding this comment.
How about removing messageQueue completely and have all the logic go based off if pendingPromises has anything in it? Then the type for the key could include resolve, reject, payload, method. This way we don't need 2 different queues.
test/jest/roktManager.spec.ts
Outdated
There was a problem hiding this comment.
nit: Add this identical test above to line 1103 but it'd be
expect(roktManager['pendingPromises'].has(messageId)).toBe(true);
test/jest/roktManager.spec.ts
Outdated
There was a problem hiding this comment.
Can this be combined with the first test? Seems like it's mostly doing the same thing...but adding a few extra checks.
There was a problem hiding this comment.
They're different tests. This one is handling a generic promise that resolves, but the test above handles a promise that has been rejected.
There was a problem hiding this comment.
i was referring to not the test above, but the first test should resolve pending promise with success result
test/jest/roktManager.spec.ts
Outdated
There was a problem hiding this comment.
const queuedMessage = roktManager['messageQueue'].values()[0].value;
There was a problem hiding this comment.
here and elsewhere where you have .next
test/jest/roktManager.spec.ts
Outdated
There was a problem hiding this comment.
| it.only('should create a deferred promise with unique messageId', () => { | |
| it('should create a deferred promise with unique messageId', () => { |
|
rmi22186
left a comment
There was a problem hiding this comment.
tested locally and looks good. great work!
this will require a docs update. we need to let customers know to wrap selectplacement in mParticle.ready here https://docs.rokt.com/developers/integration-guides/getting-started/ecommerce/ecommerce-sdk-integration#5-show-a-placement
## [2.43.2](v2.43.1...v2.43.2) (2025-08-12) ### Bug Fixes * Refactor RoktManager with deferred call handling and message queue processing ([#1051](#1051)) ([a8b8cbc](a8b8cbc))
|
🎉 This PR is included in version 2.43.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |



Instructions
developmentSummary
Testing Plan
selectPlacementsthat triggers before the mParticle web sdk finishes loading the Rokt Web Kit. The call should return placements correctly after queuing.As an example:
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)