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

Minor corrections #2

Merged
merged 15 commits into from
Nov 21, 2024
Merged

Minor corrections #2

merged 15 commits into from
Nov 21, 2024

Conversation

adams85
Copy link
Collaborator

@adams85 adams85 commented Nov 8, 2024

Describe the purpose of your pull request

Bug fixes:

  • Adjusts the browser and chrome-extension platforms to work correctly in web workers too.
    • Implements an IndexedDB-backed config cache and uses it when running in a web worker (as LocalStorage is not available in web workers).
    • Corrects DefaultQueryStringProvider to make it work in web workers (as window global variable is not available web workers.)
    • Also, adds a sample app which runs the SDK in a web worker.
  • A bunch of minor corrections (especially to project and build configuration).

Breaking changes:

  • Change SettingKeyValue to a plain object type. (Very low impact expected. It's unlikely that consumers create instances of this type but even then they may not use the ctor.)
  • Change FlagOverrides to a plain object type. (Internal breaking change only.)
  • Rename LocalStorageCache to LocalStorageConfigCache and ChromeLocalStorageCache to ChromeLocalStorageConfigCache. (Internal breaking change only.)

Related issues (only if applicable)

n/a

Requirement checklist (only if applicable)

  • I have covered the applied changes with automated tests.
  • I have executed the full automated test set against my changes.
  • I have validated my changes against all supported platform versions.
  • I have read and accepted the contribution agreement.

@adams85 adams85 force-pushed the minor-corrections branch 2 times, most recently from 832ab4b to 17efa93 Compare November 8, 2024 20:01
@adams85 adams85 force-pushed the minor-corrections branch 8 times, most recently from 408626a to 9110ba7 Compare November 13, 2024 13:16
@@ -91,7 +89,7 @@ export interface IQueryStringProvider {
}

class DefaultQueryStringProvider implements IQueryStringProvider {
get currentValue() { return window?.location.search; }
get currentValue() { if (typeof location !== "undefined") return location?.search; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an else could be good here just for the eye.

const transaction = db.transaction(OBJECT_STORE_NAME, "readwrite");
const store = transaction.objectStore(OBJECT_STORE_NAME);
store.put(value, key);
transaction.oncomplete = () => resolve();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not 100% sure how the transaction works here, but maybe if the store.put completes before this line, the transaction.oncomplete = () => resolve(); will not fire? Just a guess, but maybe it would be safer to put the transaction.oncomplete and onerror before the store.put

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the JS runtime implementations I know of use an event loop-based, single-threaded execution model. So put doesn't have a chance to fire the complete event before the currently processed JS code finishes.

Regardless, I'll change it, just in case.

const store = transaction.objectStore(OBJECT_STORE_NAME);
const storeRequest = store.get(key);
let value: string | undefined;
storeRequest.onsuccess = event => value = (event.target as IDBRequest<any>).result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here? not sure, just a feeling

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4.2% Duplication on New Code (required ≤ 3%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@adams85 adams85 merged commit 9e67406 into master Nov 21, 2024
37 of 38 checks passed
@z4kn4fein z4kn4fein deleted the minor-corrections branch November 25, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants