-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Move the assert module to userland #19652
Comments
I am surprised that adding new features is considered "bad". I would have expected it to be good that this module is finally getting in nice shape. And I personally have been involved a lot in further optimizing There are some quirks that can not easily be removed due to historical reasons but that is what the new
|
Expanding the scope of assert to include diffs and colored error messages is a Pandora's box of style fixes and introduces a huge amount of subtle bugs that need to be fixed. Fixing those in node core on a slow release cycle seems like a quite painful flow. Looking through the colored diff that just went in, this also means node core now includes hard coded knowledge of several specific terminals and CI environments. This is a quite rapidly changing landscape, so this code will get out of date. Also add a maintainer of environments that have not been blessed by node core I question why my specific thing is not deemed worthy of color. Are these really discussions that belong in what keeps being referred to as a small core? |
@Munter color support and if Speaking about bugs before there is an issue is somewhat surprising to me. If Node.js is good in one thing though, it is fixing bugs. That is done all the time and does not have a slow release cycle. That is done almost once a week. What is slow is breaking code. The current color detection is something that will likely need some further work but having that in Node.js is important, otherwise using colors is not really an option. I am traveling this week though and am fairly busy, so I did not get back to it yet. |
@BridgeAR I don't think anybody was suggesting new features in core are bad, but we are asking for the rationale behind this being included in core. Of course colour detection would be required if colours are desired in core, but the underlying question is exactly whether this is this really territory for core or is rather much better solved in userland? At least from my perspective it has been encouraged to do user facing libraries in the ecosystem for a long time and there are some amazing solutions that already exist there. Also, I'd really like to see a specific response to the point raised by @Munter about hard coding terminal knowledge in core - how will this be handled? If this went in, would there be flags or environment variables added to force coloured output for example in CI (this is well known to require a helping hand - see --color options to all the test runners) or if my system happens not to support it? There things would need to be addressed, though I stand by my reservations. Again, any and all work done by folks on core is very much appreciated by those of us using the platform. In this case however there are well documented long standing issues with the assert API. I don't think further encouraging it's use is the right thing and, as someone who has written a library that aimed for bug-for-bug compatibility with assert to provide users an upgrade path, I would be pretty worried about introducing changes to the module. |
Here is the thing:
So I am -1 for removing assert, mostly because it will undoubtedly "break userland" in some subtle way, it would require more work than it would to keep things as they are - and people don't really feel this is a big maintenance burden. If the discussion was about introducing assert I believe the barrier would have been different. |
(Tangentially related, happy to open up a separate issue if you want.) While I don't have any opinions on whether EDIT: Or even better: having structured data in general on the error |
@SimenB that's a really good point! I wrote a drop in replacement for assert (https://github.com/alexjeffburke/assert-the-unexpected) that emulates the API but runs assertions via the Unexpected assertion framework. Part of this emulation was to make sure thrown errors were still of type AssertionError and the messages matched in case anybody was checking the contents of the .message property and I'm not really what effect the colouring code will have (especially if it's on by default). Finally, in the spirit of trying to share knowledge - there are some pitfalls with extending messages and at least a large number of mocha releases need "message" to equal the start of "stack" or things get printed twice. |
@SimenB - hey, if you're up for it we're doing a session for user feedback and tooling folk - you're more than welcome to provide this feedback directly (it's welcome and will likely have an impact) nodejs/user-feedback#37
That can also be a feature request or a configuration set with an environment variable (CC @BridgeAR @addaleax ), there is no need to go on tangents you're welcome to open an issue and request it as a feature request. |
Moving |
@benjamingr sounds good! I'll create an issue after Easter |
I'm a bit disappointed that this issue is closed before the discussion even started. First off, the fact that core uses I agree that it would be unrealistic for core to stop exposing the module at this point, even with a long, well thought out deprecation strategy. Still, I hoped that we could have a strategic discussion about this and maybe even agree that:
The new features are probably fine and well implemented, but I still think it's bad judgement to land them, thus further encouraging the use of |
Whether something is a distraction or not seems like something only the maintainers can judge. |
@ljharb, as a contributor, observer and user I believe I'm entitled to an opinion? |
I'm quite sympathetic to this idea and have often considered proposing that the top level |
Your participation and contribution is always welcome, it doesn't look like any of your prior commits to Node.js are in the assert module or in its area. Everyone responding not from core (@papandreou , @Munter, @alexjeffburke)* don't have a whole lot of prior participation in I appreciate your contributions to Node and the participation here but I'm not sure it's fair to say the issue was closed without discussion. Multiple TSC members (James and Colin) and multiple core collaborators me and Ruben) have responded on the removal of assert from core. Honestly we just don't see the motivation for doing so much work and causing the ecosystem so much breakage for something we don't see maintaining as a burden.
|
@benjamingr I don't think our affiliation is at all relevant and for the record I'm the only person on this thread that works at One. The reason for our commentary here is all of us have worked for years building out and contributing to an assertion framework and a whole host of plugins - what you see on GitHub, spread across our accounts, is the work that it has taken to achieve this of which an enormous amount if not the majority was done in spare personal time. Those experiences, particularly the complexity of doing this, is the synthesis for this commentary. Removal of assert might not be feasible, but I do think it's more than fair for us to ask whether giving it additional features will encourage it's use and whether that would be a good thing. I'd also like to say that we're glad to see some of the ideas about helpful diffs that assist users catch on, but we're also cautioning that it may come with a significant as yet unseen maintenance burden. You mentioned we never contributed to assert, but for a long time the module was locked and it was made clear that contributions were to be made in userland - advice that we took to heart. If there has been a policy change here it's something I've not seen communicated and I'd like to understand it. We can only do that through discussions like this and I appreciate yourself, other maintainers and those on the TSC taking time to engage in dialogue with us around this. |
@benjamingr, I was mostly responding to what seemed like an unnecessary rank pull, but thanks for taking it literally and unfolding my life story :) I don't like the notion that it requires some kind of prequalification to be heard, but I'll bite. The reason why I even have an opinion is that I've spent many hours thinking about assertion semantics and rendering of diffs while contributing to the assertion library Unexpected.js, mocha and others. Let me assure you that I'm not worried about having another competitor. I'm just painfully aware how big a task it is to get the semantics right, and the amount of bikeshedding around rendering of array/object/type-aware diffs. I don't think it makes sense for core to take on those tasks. I'd be happy to elaborate on the things that we have struggled the most with in this area, if you'd like to pursue it further. |
@papandreou @alexjeffburke if you would like to get more involved with how assert works in core, as well as have critical feedback on newish features being worked on (like Ruben's on diffs) that would be fantastic and well appreciated. More general, your feedback and contributions on the assert built in module, as well as more formal community feedback would be appreciated. Raising pain points and complexity involved in those tasks would be extra important as it would help us figure out issues before we even run into them. We mostly enhance One thing we can't do though is to remove assert entirely since it'll cause major ecosystem breakage. We have had a very painful experience with removing things that were much much smaller. Node.js takes keeping our users happy very seriously. One thing we could consider is adding a note to the docs indicating this isn't a high level module (but I guess that's true for everything else in core). I understand this might come off as frustrating, you combined likely have more assertion library experience and diff experience than us - but given our constraints (not breaking userland) I think it would be fantastic if you helped bring that experience to the table by getting more involved. If you're not sure where to start or what contributions would be well received then that's something I can definitely help with. |
I'm a bit confused here. Is there a policy against taking user land module into the node test suite to improve the developer experience? People, both in this thread, but also on other assertion libraries and diffing tools, have literally spent years thinking about this one problem and iterated to improve the developer experience for a long time. It seems wasteful to take a not-invented-here approach |
@Munter if there will be compelling reasons to use a third-party module for our internal tests then that's something I think we can and should consider. That's not the same thing as removing |
As a user of assert, I do appreciate the new features as they make the results much easier to read by default, but as a maintainer I'll have to say I share the sentiment as the OP, especially when user-land eye candies like Removing assert does not seem to be practical to me, but the fact that assert is used internally means we need to pay more attention to its size. In case you have not noticed:
The appearance of acron was how I got to learn about the new features before I actually noticed the difference in the tests. There are replacements for assert internally now (the CHECK macros) but I am somewhat skeptical about replacing the internal asserts in bulk because those macros abort instead of throwing. |
I feel that maintaining the
assert
module as part of node has been an unnecessary distraction for the project for a long time. If you search forassert
across issues and PRs, 2360 results turn up. Now major features are being added, such as diffs and colored error messages, so it seems like it's only getting worse.At the same time the module is classified as "stable" and hasn't been able to correct all the weirdness of the original CommonJS spec, leading to surprises when users don't use the "strict" and "deep" versions of the methods.
Liberating the module from core would allow it to evolve, and hopefully new users would stop picking it up "by default" and being surprised by its quirks.
The text was updated successfully, but these errors were encountered: