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(service): interpreting 0 as a boolean true #837

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

Leopoldthecoder
Copy link
Member

Summary

This PR fixes a bug where zero values are interpreted as true.

Before:

// when data.read_timeout is 0, the following evaluates to true
(data?.read_timeout || data?.read_timeout === 0) ?? 60000

After:

// when data.read_timeout is 0, the following evaluates to 0
(data?.read_timeout || data?.read_timeout === 0) ? data?.read_timeout : 60000

Fixes FTI-5437

PR Checklist

  • Naming & Structure: the files and package structure use the conventions outlined in the Creating a Package docs.
  • Tests pass: check the output of all package unit and/or component tests.
    • If this PR is the result of a bug, test coverage was added accordingly.
  • Functional: all changes do not break existing APIs, but if so, a BREAKING CHANGE commit is in place to bump the major version.
  • Conventional Commits all commits follow the conventional commit standards outlined in the main README.
  • Docs: includes a technically accurate README, and the docs have been updated accordingly based on the changes in this PR.

@Leopoldthecoder Leopoldthecoder requested review from a team as code owners October 14, 2023 06:13
Copy link
Contributor

@kaiarrowood kaiarrowood left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

Very interesting, I had to read up on nullish operator again to understand how we were getting true from this. It looks like a valid solution would also have been to just remove the === 0, but this works too.

image

@kaiarrowood kaiarrowood merged commit 3859e75 into main Oct 16, 2023
7 checks passed
@kaiarrowood kaiarrowood deleted the fix/service-form-zero-value branch October 16, 2023 13:46
@Leopoldthecoder
Copy link
Member Author

Ah yes, data?.read_timeout ?? 60000 should be enough.

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.

2 participants