Open izakfilmalter opened 4 years ago
Bump, this is still an issue....
This is still a bug...... any response?
Hi @izakfilmalter,
We have plans to rewrite this package entirely, so we will not be moving forward on this issue. If you run into a blocker feel free to reach out to our support team.
Thanks!
@jmulford-bw Is this gonna get resolved? It's been over a year and no movement. The promised rewrite of everything that solves every bug is always a lie. Do you want me to open a pr that fixes the issue?
It shouldn't be that hard to add in the monkey patch solution.
When using
Subscription.listAsync
and usingClient.globalOptions
, you only pass in one Param into the function, thequery
. Because this lib uses multiple params instead of a single param as an object, there is a chance for missing param bugs. In this case thequery
param is undefined, thecallback
param is set to thequery
though technically this is theclient
param.I made a simple test to check what is going on:
This then causes the following type error:
Other places in the lib use the following, and if you monkey patch the function with this, it works:
I see three possible solutions ranked from easiest to hardest:
Use an object param model:
The beauty of single param functions that take an object is you don't have to worry about param order or even absence. The second awesome thing about it is that any future changes to methods in this lib become really easy, want to add another param and not have it break peoples code? Done. Here is an example that resolves the biggest issue I have with the lib:
Now you don't have mutation on the params, and you have a true optional param with a safe default.
Would love to know thoughts on the three solution options, and then don't mind opening a PR to either of them. If there is no push back, I'm more than happy to convert the methods over to object params with a default value for
client
. Probably can also make acodemod
to help auto upgrade everyone's code.Link to file: https://github.com/Bandwidth/node-numbers/blob/8a765bd6bedad03d9bc5b892075a6f5300f7ab66/lib/subscription.js#L27