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

Fixed functions that return null causing crashes #31

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

danieljharvey
Copy link
Contributor

@danieljharvey danieljharvey commented Apr 15, 2024

This function that checks for a Promise breaks when a non-async function returns null, as typeof null === "object". This adds a basic truthiness check.

Copy link
Collaborator

@daniel-chambers daniel-chambers left a comment

Choose a reason for hiding this comment

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

Thanks @danieljharvey. I cleaned up the use of the any type in the code, so the compiler catches this error now. any is the worst.

I've also added some tests to cover this edge case.

@daniel-chambers daniel-chambers changed the title Fix promise check for null values Fixed functions that return null causing crashes Apr 16, 2024
@daniel-chambers daniel-chambers merged commit e2e59f5 into main Apr 16, 2024
6 checks passed
@daniel-chambers daniel-chambers deleted the djh/promise-check-breaks-on-null branch April 16, 2024 02:10
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