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 console warning including 'undefined' and a type violation #235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michaelboyles
Copy link
Contributor

This fixes the following console warning including 'undefined', if the user never specifies that config option

console.warn(`Max reconnect attempts of ${optionsRef.current.reconnectAttempts} exceeded`);

There's another instance of the same warning which null-coalesces the default of 20 before printing, which is more sensible.

It also fixes this typecast being wrong. optionsRef.current.reconnectAttempts is possibly undefined, and onReconnectStop is not declared to accept that (hence the cast, I guess).

optionsRef.current.onReconnectStop && optionsRef.current.onReconnectStop(optionsRef.current.reconnectAttempts as number);

After I'd changed that, my IDE warned me that reconnect section was an exact duplicate. I don't always pay attention to that warning, but since there were 2 functions doing the same thing, one with bugs and one without, it seemed a good candidate to extract to new a function so that they don't diverge again.

This change is split into 2 commits: the functional change to fix the bugs, then the refactor.

@robtaussig Please review!

…ceeded"

Also fixes a bug where onReconnectStop can be given undefined as an arg, when it's defined to only accept 'number'
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.

1 participant