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

release-20.1: Check value of gc.ttlseconds before rendering to prevent TypeError #52813

Merged
merged 2 commits into from
Aug 24, 2020
Merged

release-20.1: Check value of gc.ttlseconds before rendering to prevent TypeError #52813

merged 2 commits into from
Aug 24, 2020

Conversation

nathanstilwell
Copy link
Contributor

Backport 2/2 commits from #52721.

/cc @cockroachdb/release


In a reported case from a customer, zone_config.gc is undefined and
accessing ttl_seconds on a null threw an error that stopped page
rendering.

bundle.js:49 TypeError: Cannot read property 'ttl_seconds' of null
    at t.e.renderZone (bundle.js:83)
    at t.value (bundle.js:83)
    at Xi (bundle.js:49)
    at $i (bundle.js:49)
    at Ts (bundle.js:49)
    at Cc (bundle.js:49)
    at Pc (bundle.js:49)
    at wc (bundle.js:49)
    at bundle.js:49
    at t.unstable_runWithPriority (bundle.js:57)

I'm adding a lodash/get call here with null as a default return to
prevent a TypeError. This is generally a good idea whenever you are
accessing anything that could be undefined in javascript.

Nathan Stilwell added 2 commits August 14, 2020 09:54
In a reported case from a customer, `zone_config.gc` is undefined and
accessing `ttl_seconds` on a null threw an error that stopped page
rendering.

I'm adding a lodash/get call here with `null` as a default return to
prevent a TypeError. This is generally a good idea whenever you are
accessing anything that could be undefined in javascript.

Release note: None
As of TypeScript 3.7, the optional chaining operator provides roughly
the same purpose as lodash/get (with better syntax in my opinion). I am
removing get() and instead depending on an optional chain.

There was also concern about the correctness of displaying
`gc.ttlseconds` as a null value, which is valid. The error I am seeking
to prevent here is that `gc` is null or undefined, and so if there is no
`gc` value then I am instead choosing not to display a value at all.

Release note (bug fix): don't display a value for gc.ttlseconds if not
set
@nathanstilwell nathanstilwell requested a review from a team August 14, 2020 13:58
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nathanstilwell nathanstilwell merged commit f990441 into cockroachdb:release-20.1 Aug 24, 2020
@nathanstilwell nathanstilwell deleted the backport20.1-52721 branch August 24, 2020 16:32
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