Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User ID auctionDelay timeout bugfix #4982

Merged
merged 5 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ let configRegistry = [];
/** @type {Submodule[]} */
let submoduleRegistry = [];

/** @type {(number|undefined)} */
let timeoutID;

/** @type {(number|undefined)} */
export let syncDelay;

Expand Down Expand Up @@ -254,6 +257,7 @@ function processSubmoduleCallbacks(submodules, cb) {
// clear callback, this prop is used to test if all submodule callbacks are complete below
submodule.callback = undefined;
});
clearTimeout(timeoutID);
}

/**
Expand Down Expand Up @@ -320,9 +324,9 @@ function initializeSubmodulesAndExecuteCallbacks(continueAuction) {
}
}
utils.logInfo(`${MODULE_NAME} - auction delayed by ${auctionDelay} at most to fetch ids`);
processSubmoduleCallbacks(submodulesWithCallbacks, continueCallback);

setTimeout(continueCallback, auctionDelay);
timeoutID = setTimeout(continueCallback, auctionDelay);
processSubmoduleCallbacks(submodulesWithCallbacks, continueCallback);
} else {
// wait for auction complete before processing submodule callbacks
events.on(CONSTANTS.EVENTS.AUCTION_END, function auctionEndHandler() {
Expand Down
6 changes: 3 additions & 3 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ describe('User ID', function() {

beforeEach(function() {
sandbox = sinon.createSandbox();
sandbox.stub(global, 'setTimeout');
sandbox.stub(global, 'setTimeout').returns(2);
sandbox.stub(events, 'on');

// remove cookie
Expand Down Expand Up @@ -596,8 +596,8 @@ describe('User ID', function() {
utils.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString());

config.setConfig({
userSync: {
auctionDelay: 33,
usersync: {
auctionDelay: 200,
syncDelay: 77,
userIds: [{
name: 'mockId', storage: { name: 'MOCKID', type: 'cookie' }
Expand Down