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

fix(umd): batch requests when using plugins via UMD #902

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Feb 21, 2022

closes FX-1139
fixes #902

If you're using an UMD, execute of the algolia requester will not be the same in a plugin as in core, as they each have their own algolia requester. To prevent this, and other requesters accidentally being joined, I introduced a requesterId.

I was alternatively thinking of Symbol.for('aa.algolia-requester'), but IE11 doesn't support symbols, and it can't be polyfilled

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 21, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e011c0f:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

@Haroenv Haroenv changed the title Fx 1139 autocomplete requests not batched when using umd via script tags fix(umd): batch requests when using plugins via UMD Feb 21, 2022
@Haroenv Haroenv marked this pull request as ready for review February 21, 2022 13:33
@Haroenv
Copy link
Contributor Author

Haroenv commented Feb 21, 2022

panelContainer.querySelector<HTMLElement>('.aa-Panel')
).toBeInTheDocument();

expect(searchClient.search).toHaveBeenCalledTimes(1);
Copy link
Contributor

@tkrugg tkrugg Feb 22, 2022

Choose a reason for hiding this comment

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

nice test!

Not necessary now but I'd love to see one more test which I think would have prevented this issue: An E2E test using our UMD builds and counting requests.

Overall, having a test suite counting queries as we make changes would make a lot a sense, given the immediate impact on pricing.

Copy link
Member

Choose a reason for hiding this comment

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

Agree on the end-to-end test. I believe this was initially in the PR then removed?

I recall our end-to-end setup not to be optimal, but this is a good opportunity to fix it given that one underlying issue is how we expect all our builds to work similarly (and in this case, they don't).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there was an UMD E2E test initially indeed, but it wasn't actually easily testing for the case we were fixing. I'll recreate it in a separate PR

Copy link
Member

Choose a reason for hiding this comment

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

For the record, FX-1228 in the backlog is about this.

Haroenv and others added 2 commits February 23, 2022 10:48
Co-authored-by: Sarah Dayan <5370675+sarahdayan@users.noreply.github.com>
Copy link
Member

@sarahdayan sarahdayan left a comment

Choose a reason for hiding this comment

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

LGTM as long as the final points can be checked 👍

Thanks @Haroenv for handling this one so promptly!

…ster.ts

Co-authored-by: Sarah Dayan <5370675+sarahdayan@users.noreply.github.com>
@Haroenv Haroenv enabled auto-merge (squash) February 23, 2022 10:30
@Haroenv Haroenv merged commit 1aa3dde into next Feb 23, 2022
auto-merge was automatically disabled February 23, 2022 10:35

Pull request was closed

@Haroenv Haroenv deleted the FX-1139-autocomplete-requests-not-batched-when-using-umd-via-script-tags branch February 23, 2022 10:35
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.

None yet

3 participants