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

Race condition waiting for welcome mods to be activated on first run #9014

Closed
twschiller opened this issue Aug 16, 2024 · 5 comments · Fixed by #9042
Closed

Race condition waiting for welcome mods to be activated on first run #9014

twschiller opened this issue Aug 16, 2024 · 5 comments · Fixed by #9042
Assignees
Labels
bug Something isn't working onboarding

Comments

@twschiller
Copy link
Contributor

twschiller commented Aug 16, 2024

Describe the bug

Actual behavior

  • Some mods are activated after the welcome page is displayed to the user (from product telemetry)

Discussion

  • @mnholtz let me know if I need to move this issue to pixiebrix-app repository
@twschiller twschiller added bug Something isn't working user experience Improve the user experience (UX) labels Aug 16, 2024
@mnholtz
Copy link
Collaborator

mnholtz commented Aug 19, 2024

let me know if I need to move this issue to pixiebrix-app repository

I'm pretty sure this is the right repo

@mnholtz
Copy link
Collaborator

mnholtz commented Aug 20, 2024

Documenting my investigation so far because I have been unable to replicate my hypothesis of what is going on.

My hypothesis is that because we've debounced _activateStarterMods in starterMods.ts, we are no longer waiting for welcome mods to actually be activated before proceeding with onboarding flow logic. This would hypothetically result in this logic getting prematurely skipped over, which would result in the user not being taken to the welcome page after onboarding (although they would get welcome mods).

For example:

import { debounce } from 'lodash';

const DEBOUNCE_MS = 10_000;
const MAX_MS = 60_000;

const asyncHello = async () => {
  await setTimeout(() => {
    console.log('hello');
  }, 2000);
};

const debouncedHello = debounce(asyncHello, DEBOUNCE_MS, {
  leading: true,
  trailing: false,
  maxWait: MAX_MS,
});

debouncedHello();
debouncedHello();
debouncedHello();
console.log('hello first');

// Output
// hello first
// hello

However, due to the fact that I can't get a consistent console to be open during onboarding, I'm struggling to confirm that hypothesis.

Some thoughts here:

  1. While my above playground example seems to yield that result, it doesn't seem to actually behave that way in practice? e.g. I added a sleep to _activateStarterMods and ran the debounced external messenger method as-is, and we do seem to wait for that obviously long time (see here: https://github.com/pixiebrix/pixiebrix-extension/compare/bugfix/9014_welcome_mod_race?expand=1)
  2. We apparently originally started debouncing this method due to the onUpdate browser extension event. Add onUpdate event listener for installing starter blueprints on Playground urls #4249 I'm not sure how relevant this is anymore, as we did this two years ago. We might consider just removing the debounce.
  3. The return value from _activateStarterMods is a boolean based on whether or not mods have been activated (and does not give any more insight into why they might have not been activated). We might consider redesigning the return value to be more helpful.
  4. We might consider an alternative flow of always taking users to the welcome page regardless of welcome mod activation success. This is just something to consider, possibly for future work

Additional resources

@mnholtz mnholtz removed their assignment Aug 21, 2024
@twschiller twschiller added onboarding and removed user experience Improve the user experience (UX) labels Aug 21, 2024
@grahamlangford
Copy link
Collaborator

@twschiller any thoughts on this suggestion?

  1. We apparently originally started debouncing this method due to the onUpdate browser extension event. Add onUpdate event listener for installing starter blueprints on Playground urls #4249 I'm not sure how relevant this is anymore, as we did this two years ago. We might consider just removing the debounce.

I also want to look into this suggestion:

  1. The return value from _activateStarterMods is a boolean based on whether or not mods have been activated (and does not give any more insight into why they might have not been activated). We might consider redesigning the return value to be more helpful.

@grahamlangford grahamlangford self-assigned this Aug 21, 2024
@twschiller
Copy link
Contributor Author

twschiller commented Aug 22, 2024

We apparently originally started debouncing this method due to the onUpdate browser extension event. #4249 I'm not sure how relevant this is anymore, as we did this two years ago. We might consider just removing the debounce.

I think the reason it's there is because: 1/ starter mods are activated on first run, 2/ starter mods are activated when the user visits the welcome page. So, on the initial install where the user gets redirected to the welcome page, they'd end up getting the welcome mods 2x

From the PR description, it seems it also helped avoid a scenario on SPAs (which might have been a problem with our initial playground) where the page would trigger multiple navigation events. That part is likely less/not relevant now for the current welcome page

I also want to look into this suggestion:

Main concern would be ensuring the app code is backward compatible

@grahamlangford
Copy link
Collaborator

@twschiller we had this discussion back in April: https://github.com/pixiebrix/pixiebrix-extension/pull/8290/files#r1572440502

I'm going to pull on this thread for a bit

grahamlangford added a commit that referenced this issue Aug 22, 2024
…st run (#9042)

* starterMods -> welcomeMods

* give more context when welcome mod activation doesn't activate any mods

* remove unneeded comment; export ActivateModsResult

* review changes

* rename starterMods.ts -> welcomeMods.ts

* more renaming

* update naming for ActivatedModsResult

* update naming for ActivatedModsResult

* convert comments to jsdoc hints
grahamlangford added a commit that referenced this issue Aug 27, 2024
…st run (#9042)

* starterMods -> welcomeMods

* give more context when welcome mod activation doesn't activate any mods

* remove unneeded comment; export ActivateModsResult

* review changes

* rename starterMods.ts -> welcomeMods.ts

* more renaming

* update naming for ActivatedModsResult

* update naming for ActivatedModsResult

* convert comments to jsdoc hints
grahamlangford added a commit that referenced this issue Aug 27, 2024
* Bump @types/webextension-polyfill from 0.10.7 to 0.12.0

Bumps [@types/webextension-polyfill](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webextension-polyfill) from 0.10.7 to 0.12.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webextension-polyfill)

---
updated-dependencies:
- dependency-name: "@types/webextension-polyfill"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* type fixes

* sidebarSlice.test.ts

* editorStorage.test.ts

* checkAvailableActivatedModComponents.test.ts

* starterBrickModUtils.test.ts

* Tabs.test.tsx

* ActivatedModPanel.test.tsx

* TriggerConfiguration.test.tsx

* more files

* editorSliceHelpers.test.ts

* more files

* more strict null checks

* Revert "more strict null checks"

This reverts commit e34f806.

* Revert "more files"

This reverts commit 92a618c.

* Revert "editorSliceHelpers.test.ts"

This reverts commit 3aa28c1.

* Revert "more files"

This reverts commit 233139b.

* Revert "TriggerConfiguration.test.tsx"

This reverts commit 60bc4d4.

* Revert "ActivatedModPanel.test.tsx"

This reverts commit 8d57036.

* Revert "Tabs.test.tsx"

This reverts commit f42bfed.

* Revert "starterBrickModUtils.test.ts"

This reverts commit 10e9530.

* Revert "checkAvailableActivatedModComponents.test.ts"

This reverts commit cc6e646.

* Revert "editorStorage.test.ts"

This reverts commit 8366437.

* Revert "sidebarSlice.test.ts"

This reverts commit 256a7ac.

* Strict null checks: 95.7% (#9030)

* Revert "Revert "sidebarSlice.test.ts""

This reverts commit 274ab05.

* Revert "Revert "editorStorage.test.ts""

This reverts commit 01663a4.

* Revert "Revert "checkAvailableActivatedModComponents.test.ts""

This reverts commit 2e09285.

* Revert "Revert "starterBrickModUtils.test.ts""

This reverts commit 6a56169.

* Revert "Revert "Tabs.test.tsx""

This reverts commit db37bcf.

* Revert "Revert "ActivatedModPanel.test.tsx""

This reverts commit b9299a3.

* Revert "Revert "TriggerConfiguration.test.tsx""

This reverts commit 3357d9a.

* Revert "Revert "more files""

This reverts commit 1b2fe11.

* Revert "Revert "editorSliceHelpers.test.ts""

This reverts commit f88df33.

* Revert "Revert "more files""

This reverts commit 5eb9e61.

* Revert "Revert "more strict null checks""

This reverts commit c810d26.

* Introduce milestones constant (#9032)

* #9015: improve sidebar diagnostics telemetry (#9033)

* fix integration dependency validation in the extension console (#9036)

* fix integration dependency validation in the extension console

* select integration option during activation flow

* Revert "Bump iframe-resizer from 4.4.5 to 5.2.4 (#9023)" (#9035)

This reverts commit 4e8536d.

* Strict null checks -- 98.0% (#9038)

* saveHelpers.test.ts

* more files

* more files

* more files

* more fixes

* update snapshot

* #9014: race condition waiting for welcome mods to be activated on first run (#9042)

* starterMods -> welcomeMods

* give more context when welcome mod activation doesn't activate any mods

* remove unneeded comment; export ActivateModsResult

* review changes

* rename starterMods.ts -> welcomeMods.ts

* more renaming

* update naming for ActivatedModsResult

* update naming for ActivatedModsResult

* convert comments to jsdoc hints

* #9007 Cleanup mods page & remove standalone mod components (#9040)

* convert view items to selectors

* fix grid/list items and marketplace url

* convert the actions and add packageId to viewmodel

* fix other mod icon usages and cleanup null checks file errors

* fix more errors and add mod action tests

* buildModsList and tests

* buildGetModStatus and tests

* buildGetModVersionStatus and tests and fix names

* buildGetModSharingSource and tests

* buildCanEditModScope and tests

* buildModViewItems

* add more cases to build mods list tests and remove old tests

* fix mod slice tests

* Status tests

* fix some bugs and table layout tests

* fix tests and snapshots

* handle feature flags update

* fix types

* tweak name

* fix dead code

* null checks - ModsPageActions.test

* fix null checks issues

* cleanup

* cleanup

* add files to strict null checks

* assert not null on _recipe property

* uninstall unused package

* auto-add strictNullChecks

* memoize selector

* memoize query input and refetch another query on load

* memoize selector

* fix memoization of mod component selector

* revert memo change and add file to null checks

* fix workshop action

* reset the list properly

* fix test

* fix ref type

* fix ref again

---------

Co-authored-by: Ben Loe <ben@pixiebrix.com>
Co-authored-by: Graham Langford <grahamlangford87@gmail.com>

* Fix bug with form state migration (#9045)

* copy form state on migrate

* fix bug and add tests

* add test file to null checks

* fix word

---------

Co-authored-by: Ben Loe <ben@pixiebrix.com>

* Strict null checks -- 99.7% (#9048)

* adds files

* pr change

* swap order in if

* Bump the patch group with 4 updates (#9051)

Bumps the patch group with 4 updates: [@swc/core](https://github.com/swc-project/swc), [knip](https://github.com/webpro-nl/knip/tree/HEAD/packages/knip), [otpauth](https://github.com/hectorm/otpauth) and [sass-loader](https://github.com/webpack-contrib/sass-loader).


Updates `@swc/core` from 1.7.11 to 1.7.18
- [Release notes](https://github.com/swc-project/swc/releases)
- [Changelog](https://github.com/swc-project/swc/blob/main/CHANGELOG.md)
- [Commits](swc-project/swc@v1.7.11...v1.7.18)

Updates `knip` from 5.27.2 to 5.27.3
- [Release notes](https://github.com/webpro-nl/knip/releases)
- [Changelog](https://github.com/webpro-nl/knip/blob/main/packages/knip/.release-it.json)
- [Commits](https://github.com/webpro-nl/knip/commits/5.27.3/packages/knip)

Updates `otpauth` from 9.3.1 to 9.3.2
- [Release notes](https://github.com/hectorm/otpauth/releases)
- [Commits](hectorm/otpauth@v9.3.1...v9.3.2)

Updates `sass-loader` from 16.0.0 to 16.0.1
- [Release notes](https://github.com/webpack-contrib/sass-loader/releases)
- [Changelog](https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/sass-loader@v16.0.0...v16.0.1)

---
updated-dependencies:
- dependency-name: "@swc/core"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: knip
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: otpauth
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: sass-loader
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @testing-library/jest-dom from 6.4.8 to 6.5.0 (#9055)

Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 6.4.8 to 6.5.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](testing-library/jest-dom@v6.4.8...v6.5.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @types/node from 22.4.0 to 22.5.0 (#9053)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.4.0 to 22.5.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* #9039: restrict public marketplace activation (#9063)

* Bump ace-builds from 1.35.4 to 1.36.0 (#9059)

Bumps [ace-builds](https://github.com/ajaxorg/ace-builds) from 1.35.4 to 1.36.0.
- [Release notes](https://github.com/ajaxorg/ace-builds/releases)
- [Changelog](https://github.com/ajaxorg/ace-builds/blob/master/CHANGELOG.md)
- [Commits](ajaxorg/ace-builds@v1.35.4...v1.36.0)

---
updated-dependencies:
- dependency-name: ace-builds
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump tj-actions/changed-files from 44 to 45 (#9050)

Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 44 to 45.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](tj-actions/changed-files@v44...v45)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump webpack from 5.91.0 to 5.94.0 (#9054)

Bumps [webpack](https://github.com/webpack/webpack) from 5.91.0 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.91.0...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @cfworker/json-schema from 1.12.8 to 2.0.1 (#9061)

Bumps [@cfworker/json-schema](https://github.com/cfworker/cfworker) from 1.12.8 to 2.0.1.
- [Release notes](https://github.com/cfworker/cfworker/releases)
- [Commits](https://github.com/cfworker/cfworker/compare/@cfworker/json-schema@1.12.8...@cfworker/json-schema@2.0.1)

---
updated-dependencies:
- dependency-name: "@cfworker/json-schema"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bug - Fix redux persist migrations for sidebar state, related to welcome mod activation (#9067)

* fix migrate max version function

* update test

---------

Co-authored-by: Ben Loe <ben@pixiebrix.com>

* Strict Null Checks Final (#9049)

* adds files

* wip

* enforce strict null checks for all files

* lint fixes

* handle bad comment

* pr review changes

* missed file save

* Bump @sinonjs/fake-timers from 11.2.2 to 13.0.1 (#9066)

Bumps [@sinonjs/fake-timers](https://github.com/sinonjs/fake-timers) from 11.2.2 to 13.0.1.
- [Release notes](https://github.com/sinonjs/fake-timers/releases)
- [Changelog](https://github.com/sinonjs/fake-timers/blob/main/CHANGELOG.md)
- [Commits](sinonjs/fake-timers@v11.2.2...v13.0.1)

---
updated-dependencies:
- dependency-name: "@sinonjs/fake-timers"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @axe-core/playwright from 4.9.1 to 4.10.0 (#9052)

Bumps [@axe-core/playwright](https://github.com/dequelabs/axe-core-npm) from 4.9.1 to 4.10.0.
- [Release notes](https://github.com/dequelabs/axe-core-npm/releases)
- [Changelog](https://github.com/dequelabs/axe-core-npm/blob/v4.10.0/CHANGELOG.md)
- [Commits](dequelabs/axe-core-npm@v4.9.1...v4.10.0)

---
updated-dependencies:
- dependency-name: "@axe-core/playwright"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @total-typescript/ts-reset from 0.5.1 to 0.6.0 (#9057)

* Bump @total-typescript/ts-reset from 0.5.1 to 0.6.0

Bumps [@total-typescript/ts-reset](https://github.com/total-typescript/ts-reset) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/total-typescript/ts-reset/releases)
- [Changelog](https://github.com/mattpocock/ts-reset/blob/main/CHANGELOG.md)
- [Commits](https://github.com/total-typescript/ts-reset/commits)

---
updated-dependencies:
- dependency-name: "@total-typescript/ts-reset"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix Map typings

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Graham Langford <grahamlangford87@gmail.com>

* fix typings

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Graham Langford <grahamlangford87@gmail.com>
Co-authored-by: Graham Langford <30706330+grahamlangford@users.noreply.github.com>
Co-authored-by: Todd Schiller <todd.schiller@gmail.com>
Co-authored-by: Ben Loe <below413@gmail.com>
Co-authored-by: Ben Loe <ben@pixiebrix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working onboarding
Projects
None yet
3 participants