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

prepare 3.2.10 release #30

Merged
merged 118 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
ad35601
initial move of code from js-client-sdk-private
eli-darkly Oct 30, 2019
abd39cd
changelog note
eli-darkly Oct 30, 2019
d64ad13
rm obsolete comment
eli-darkly Oct 30, 2019
05fa2ea
add npm audit helper
eli-darkly Oct 30, 2019
722b6f4
update babel, jest, rollup
eli-darkly Oct 30, 2019
83156f4
fix rollup config
eli-darkly Oct 30, 2019
c062853
fix ES build, dependency cleanup
eli-darkly Oct 30, 2019
5c0e2ac
add Releaser metadata
eli-darkly Oct 30, 2019
2a16af0
Update babel config to work in `test` without `useBuiltIns`
zmdavis Oct 30, 2019
e333469
Merge pull request #1 from launchdarkly/eb/update-dev-tools
eli-darkly Oct 31, 2019
f09a83a
Merge pull request #3 from launchdarkly/zdavis/babel-config
eli-darkly Oct 31, 2019
55c3852
copyedits
eli-darkly Oct 31, 2019
d361672
fix misnamed directory
eli-darkly Nov 1, 2019
f4eb20a
Merge pull request #2 from launchdarkly/eb/ch48393/initial
eli-darkly Nov 4, 2019
f072529
use spread operator instead of Object.assign
eli-darkly Nov 4, 2019
7c1299e
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Nov 4, 2019
957f477
Merge pull request #4 from launchdarkly/eb/ch54985/object-assign
eli-darkly Nov 4, 2019
a57c404
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Nov 4, 2019
1539659
add issue templates
eli-darkly Nov 4, 2019
013c273
add babel-eslint
eli-darkly Nov 4, 2019
db12eca
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Nov 4, 2019
087773b
merge from public after release
LaunchDarklyCI Nov 4, 2019
5bac01d
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
bwoskow-ld Nov 7, 2019
e145270
add event capacity config property
eli-darkly Dec 3, 2019
34ed8a5
re-add deprecation warning on samplingInterval
eli-darkly Dec 3, 2019
2ef59bc
Merge pull request #5 from launchdarkly/eb/ch57883/event-capacity
eli-darkly Dec 3, 2019
33d0311
Merge pull request #6 from launchdarkly/eb/ch38635/deprecation-comment
eli-darkly Dec 3, 2019
3c3e22a
better config validation
eli-darkly Dec 3, 2019
5cfb5a0
remove rollup-plugins-node-resolve
eli-darkly Dec 4, 2019
3c0794a
use newer Rollup node-resolve plugin
eli-darkly Dec 4, 2019
6385bb7
rm rollup-plugin-includepaths (unused)
eli-darkly Dec 4, 2019
c1b6f09
npm audit fix (handlebars dependency from jest)
eli-darkly Dec 4, 2019
11e46e1
comment
eli-darkly Dec 4, 2019
7cc15ba
copyedit
eli-darkly Dec 4, 2019
c44052b
Merge pull request #7 from launchdarkly/eb/ch57985/config-validation
eli-darkly Dec 4, 2019
9dbb6b2
Merge pull request #8 from launchdarkly/eb/ch57982/rollup-builtins
eli-darkly Dec 4, 2019
1cf982b
use new test helpers + misc test cleanup
eli-darkly Dec 5, 2019
9077edf
clean up stream testing logic
eli-darkly Dec 6, 2019
3f77514
fix hash parameter
eli-darkly Dec 6, 2019
d1fe985
Merge pull request #9 from launchdarkly/eb/ch57131/test-cleanup
eli-darkly Dec 7, 2019
d0de600
linter
eli-darkly Dec 7, 2019
b0168db
Merge pull request #10 from launchdarkly/eb/ch57131/stream-tests
eli-darkly Dec 7, 2019
b489fb2
clearer way to model the config option defaults/types
eli-darkly Dec 9, 2019
a32383c
test improvements
eli-darkly Dec 9, 2019
cdc1e96
change internal param name
eli-darkly Dec 9, 2019
2fcfa79
comment
eli-darkly Dec 9, 2019
88aa416
fix default logger logic
eli-darkly Dec 9, 2019
ceb9e3d
simpler way to enforce minimum values
eli-darkly Dec 10, 2019
58ee382
Merge pull request #12 from launchdarkly/eb/ch57985/config-validation…
eli-darkly Dec 10, 2019
50bc6aa
implement diagnostic events in common JS package (#11)
eli-darkly Dec 11, 2019
53a8590
add support for function type in config options
eli-darkly Dec 12, 2019
0a782ca
add support for function type in config options (#13)
eli-darkly Dec 12, 2019
04130f7
add wrapper metadata options and fix custom header logic
eli-darkly Dec 12, 2019
9491e16
lint
eli-darkly Dec 12, 2019
c9e7d7e
Merge branch 'eb/ch57741/wrapper-desc' into eb/ch57741/diagnostic-wra…
eli-darkly Dec 12, 2019
2610fc7
lint
eli-darkly Dec 12, 2019
fd7e2bb
remove image-loading logic from common code, replace it with an abstr…
eli-darkly Dec 12, 2019
0f28ba9
Merge branch 'eb/ch57741/wrapper-desc' into eb/ch59034/no-image-loading
eli-darkly Dec 12, 2019
f40f19b
Merge branch 'eb/ch59034/no-image-loading' into eb/ch57741/diagnostic…
eli-darkly Dec 12, 2019
5bdb140
Merge branch 'master' into diagnostic-events
eli-darkly Dec 12, 2019
fedb366
Merge branch 'eb/ch57741/diagnostic-wrapper' into diagnostic-events
eli-darkly Dec 12, 2019
385cbcd
add validation for options.streaming
eli-darkly Dec 12, 2019
2affe2f
Merge branch 'eb/ch57741/wrapper-desc' into eb/ch59034/no-image-loading
eli-darkly Dec 12, 2019
9e653e8
typo
eli-darkly Dec 12, 2019
c88839c
rm unused params
eli-darkly Dec 12, 2019
6f50448
merge from public after release
LaunchDarklyCI Dec 13, 2019
b4e0bfd
typo in comment
eli-darkly Dec 13, 2019
c5494b1
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Dec 13, 2019
6ef084a
Merge pull request #14 from launchdarkly/eb/ch57741/wrapper-desc
eli-darkly Dec 13, 2019
f3815bc
Merge pull request #15 from launchdarkly/eb/ch59034/no-image-loading
eli-darkly Dec 13, 2019
32d767f
misc fixes to merged code from external PR
eli-darkly Dec 13, 2019
7d4f67d
merge from public after release
LaunchDarklyCI Dec 13, 2019
3ba6e27
add event payload ID header
eli-darkly Jan 14, 2020
d9499df
Merge pull request #16 from launchdarkly/eb/ch61092/payload-id
eli-darkly Jan 15, 2020
a670c7f
merge from public after release
LaunchDarklyCI Jan 15, 2020
547b309
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 30, 2020
15b5072
npm audit fix
eli-darkly Jan 30, 2020
6294b02
change exact dependencies to best-compatible
eli-darkly Jan 30, 2020
f190577
Merge pull request #17 from launchdarkly/eb/ch63559/relax-deps
eli-darkly Feb 1, 2020
7068968
merge from public after release
LaunchDarklyCI Feb 1, 2020
8c42690
standardize linting
eli-darkly Feb 11, 2020
f838fb3
disallow "window" and "document"
eli-darkly Feb 11, 2020
5064c3b
Merge branch 'master' into diagnostic-events
eli-darkly Feb 11, 2020
ade0261
Merge pull request #18 from launchdarkly/eb/ch65303/linting
eli-darkly Feb 11, 2020
8db5bc2
Merge branch 'diagnostic-events'
eli-darkly Feb 11, 2020
b4affad
improve diag event tests + debug logging
eli-darkly Feb 12, 2020
a01e65f
misc cleanup
eli-darkly Feb 12, 2020
7862b29
Merge pull request #19 from launchdarkly/eb/ch57741/diag-tests-fixes
eli-darkly Feb 12, 2020
4140b85
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Feb 12, 2020
20c655d
fix updating secure mode hash with identify()
eli-darkly Feb 13, 2020
8bf67c4
Merge pull request #20 from launchdarkly/eb/ch65728/identify-hash
eli-darkly Feb 13, 2020
ad44049
merge from public after release
LaunchDarklyCI Feb 13, 2020
232a404
don't omit streamInits.failed when it's false
eli-darkly Feb 14, 2020
bafa8da
Merge pull request #21 from launchdarkly/eb/ch65817/diag-explicit-false
eli-darkly Feb 14, 2020
ab182f0
merge from public after release
LaunchDarklyCI Feb 14, 2020
f954124
clean up init state logic, prevent unhandled rejections
eli-darkly Mar 5, 2020
78db776
lint
eli-darkly Mar 5, 2020
3136564
Merge pull request #22 from launchdarkly/eb/ch68119/init-state-error
eli-darkly Mar 6, 2020
bd3f238
merge from public after release
LaunchDarklyCI Mar 6, 2020
54099c8
less strict matching of json content-type header
eli-darkly Mar 18, 2020
e4c792c
Merge pull request #23 from launchdarkly/eb/ch69815/content-type
eli-darkly Mar 18, 2020
c610ffd
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Mar 18, 2020
5a323d8
merge from public after release
LaunchDarklyCI Mar 18, 2020
c974e2c
remove unsafe usage of hasOwnProperty
eli-darkly Mar 18, 2020
f5177c7
Merge pull request #24 from launchdarkly/eb/ch69855/has-own-property
eli-darkly Mar 18, 2020
93ee649
merge from public after release
LaunchDarklyCI Mar 18, 2020
e7ee64a
console logger must tolerate console object not always existing
eli-darkly Mar 30, 2020
c2402de
Merge pull request #25 from launchdarkly/eb/ch71507/no-console
eli-darkly Mar 31, 2020
68f359b
merge from public after release
LaunchDarklyCI Mar 31, 2020
a84b943
fix double initialization of diagnostics manager
eli-darkly May 1, 2020
14134c9
Merge pull request #26 from launchdarkly/eb/ch75557/extra-diagnostics
eli-darkly May 1, 2020
bdc9335
merge from public after release
LaunchDarklyCI May 1, 2020
5aac8a2
fix TypeScript declaration for track() and add more TS compilation te…
eli-darkly May 13, 2020
ca937d3
merge from public after release
LaunchDarklyCI May 13, 2020
fc3a857
remove startsWith usage (#28)
bwoskow-ld Jul 10, 2020
88125a7
merge from public after release
LaunchDarklyCI Jul 10, 2020
b572761
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Aug 5, 2020
1359aaf
prevent poll caused by a stream ping from overwriting later poll for …
eli-darkly Sep 12, 2020
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
55 changes: 4 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@rollup/plugin-replace": "^2.2.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.1.0",
"chai": "^4.1.2",
"cross-env": "^5.1.4",
"eslint": "^6.8.0",
"eslint-config-prettier": "^2.9.0",
Expand Down
48 changes: 47 additions & 1 deletion src/__tests__/LDClient-streaming-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as utils from '../utils';

import { eventSink, sleepAsync, withCloseable } from 'launchdarkly-js-test-helpers';
import { AsyncQueue, eventSink, sleepAsync, withCloseable } from 'launchdarkly-js-test-helpers';

import EventSource from './EventSource-mock';
import { respondJson } from './mockHttp';
Expand Down Expand Up @@ -250,6 +250,52 @@ describe('LDClient streaming', () => {
});
});

it("poll request triggered by stream ping can't overwrite another user's flags", async () => {
const otherUser = { key: 'otherUser' };
const initUserBase64 = utils.base64URLEncode(JSON.stringify(user));
const otherUserBase64 = utils.base64URLEncode(JSON.stringify(otherUser));

await withClientAndServer({}, async (client, server) => {
const reqRespQueue = new AsyncQueue();
server.byDefault((req, resp) => {
reqRespQueue.add({ req: req, resp: resp });
});

const initPromise = client.waitForInitialization();
const poll1 = await reqRespQueue.take();
expect(poll1.req.path).toContain(initUserBase64);
respondJson({ flagKey: { value: 1 } })(poll1.req, poll1.resp);
await initPromise;

// The flag value is now 1, from the initial poll
expect(client.variation('flagKey')).toEqual(1);

client.setStreaming(true);
const stream = await expectStreamConnecting(fullStreamUrlWithUser);

stream.eventSource.mockEmit('ping');
const poll2 = await reqRespQueue.take();
// poll2 is the poll request that was triggered by the ping; don't respond to it yet
expect(poll2.req.path).toContain(initUserBase64);

const identifyPromise = client.identify(otherUser);
const poll3 = await reqRespQueue.take();
// poll3 is the poll request for the identify
expect(poll3.req.path).toContain(otherUserBase64);

// Now let's say poll3 completes first, setting the flag value to 3 for the new user
respondJson({ flagKey: { value: 3 } })(poll3.req, poll3.resp);

// And then poll2, which was for the previous user, completes with a flag value of 2
respondJson({ flagKey: { value: 2 } })(poll2.req, poll2.resp);

await identifyPromise;

// The flag value should now be 3, not 2
expect(client.variation('flagKey')).toEqual(3);
});
});

it('handles stream put message by updating flags', async () => {
await withClientAndServer({}, async client => {
await client.waitForInitialization();
Expand Down
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,16 @@ export function initialize(env, user, specifiedOptions, platform, extraOptionDef
stream.connect(ident.getUser(), hash, {
ping: function() {
logger.debug(messages.debugStreamPing());
const userAtTimeOfPingEvent = ident.getUser();
requestor
.fetchFlagSettings(ident.getUser(), hash)
.then(requestedFlags => replaceAllFlags(requestedFlags || {}))
.fetchFlagSettings(userAtTimeOfPingEvent, hash)
.then(requestedFlags => {
// Check whether the current user is still the same - we don't want to overwrite the flags if
// the application has called identify() while this request was in progress
if (utils.deepEquals(userAtTimeOfPingEvent, ident.getUser())) {
replaceAllFlags(requestedFlags || {});
}
})
.catch(err => {
emitter.maybeReportError(new errors.LDFlagFetchError(messages.errorFetchingFlags(err)));
});
Expand Down