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: [M3-8894] - Linode Create crash when selected a Linode with a type that is null #11247

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
1 change: 1 addition & 0 deletions packages/manager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- UI bugs on the Object Storage bucket and access key landing pages ([#11187](https://github.com/linode/manager/pull/11187))
- Animation for VPC subnet drawers ([#11195](https://github.com/linode/manager/pull/11195))
- DBaaS enable creation of two node clusters ([#11218](https://github.com/linode/manager/pull/11218))
- Crash on the Linode Create flow when a Linode with a `type` of `null` is selected ([#11247](https://github.com/linode/manager/pull/11247))

### Tech Stories:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const Region = React.memo(() => {

const { data: type } = useTypeQuery(
selectedLinode?.type ?? '',
Boolean(selectedLinode)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what triggered the crash. The query would be enabled if any Linode was selected (even if it has a type that is null), which would cause Cloud Manager to GET /v4/linode/types/ , which would incorrectly store a paginated list of Linode types in the cache, which put us in a bad state leading to a crash.

To fix this, the query should only be enabled if the Linode's type is truthy.

Boolean(selectedLinode?.type)
);

const isLinodeCreateRestricted = useRestrictedGlobalGrantCheck({
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/queries/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useSpecificTypes = (types: string[], enabled = true) => {

return useQueries({
queries: types.map<UseQueryOptions<LinodeType, APIError[]>>((type) => ({
enabled,
enabled: enabled && Boolean(type),
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't the direct fix, but makes this query much safer from this same bug happening again in the future.

...linodeQueries.types._ctx.type(type),
...queryPresets.oneTimeFetch,
initialData() {
Expand Down