-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
createClient url+tls invariant violation check #2835
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
static parseURL(url: string): RedisClientOptions & { | ||
socket: Exclude<RedisClientOptions['socket'], undefined> & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
union is a bit wordy, please guide me where you'd like to define an interface if you think it's not ok to inline that
throw new TypeError('Invalid protocol'); | ||
} | ||
|
||
parsed.socket.tls = protocol === 'rediss:'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"DRY enough": at this point protocol
is a literal union and won't accept anything except those two literals
if (options?.database) { | ||
this.#selectedDB = options.database; | ||
} | ||
|
||
if (options) { | ||
return RedisClient.parseOptions(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better to put before this.#selectedDB = options.database
but it's a private method use in a constructor anyways?
Description
on url
rediss:..
+ tls: false passed or on url:redis:
+ rls: true passed, the lib blows up during connection with a non-descriptive errorI explicitly check for this invariant violation during initialisation
this.#selectedDB = options.database;
in#initiateOptions
I dare not to touchtls
(it did this anyways, implicitly, by blowing up the connection on wrong tls passed)#initiateOptions
was implemented (let me know if you'd like me to not-mutate the argument; I'd actually prefer it this way)tls
explicitly to boolean if it wasn't set but anurl
was passed: reasons are both technical (I needed to test without changing your interfaces much) and logical:tls
undefined with URL:redis[s]:
seems to be an incorrect invariant anywaysOptions:
Checklist
npm test
pass with this change (including linting)?