The State of Node.js Core


Node.js, as a platform, is constantly changing and evolving. Node's core is a melting pot of features from our own community, as well as dependencies such as V8 and libuv. This talk will cover the latest developments in Node core.


Hi everyone, thank you for coming to my talk. Today I'm going to be talking about the state of node.js core. So right off the bat I wanted to start off with some download metrics. These are metrics for the past roughly two years, and you can see from the trend that the number of downloads from continues to go up and to the right, with the notable exception of two big traffic dips related to the Christmas holiday and things like that. But yeah, Node is still trending up and to the right. Next I wanted to talk about the ecosystem. This is a graph from, which is comparing ecosystem size of npm compared to some of the other popular package registries out there for things like rust and Java and Ruby and whatnot. So this is not necessarily representative of Node core, but of the larger ecosystem. So npm is the only package manager on this graph that has over two million packages. javascript is by far the largest ecosystem in the world. It does come with a few disclaimers, so npm does host things that are not just node.js modules, so there are other things on there. Not all modules are of great quality. There are some really nice packages out there. There are some other ones that probably don't get used a lot or shouldn't get used a lot. But just for a general trend of the ecosystem health, I think this is pretty representative. So next I wanted to talk about Node's long-term support schedule, also known as LTS. So back in 2015, Node created a LTS plan to kind of balance individuals and developers with wanting to land as many features as quickly as possible with enterprise uses, which kind of value stability over the course of years, not just days or weeks. And so we came up with this plan where twice per calendar year in April and October, we would release a new SEMVer major from the project. And so you can see here in the graph at the very top, the unstable bar labeled main. That is where all active development in the project goes. So patches, new features, breaking changes, everything lands on the main branch. And then we maintain several release branches that we cherry pick commits back to whenever we do a release. And so you can see here that right now we have Node 14, 16, 18, 19, and 20. Well, 20 is upcoming, sorry, as active or upcoming release branches. So this year in April, we'll release version 20. And then in October, we'll release version 21. So we do odd-numbered releases in October, even-numbered releases in April. The latest major release will become what we call the current release line for six months. So right now Node 19 is the current release. And then after that six-month period, if it's an odd-numbered release, it'll go into a shortened maintenance period where it'll receive things like security fixes and whatnot. But it's really just kind of a grace period for people to migrate off. Whereas the even-numbered releases go into what we call active LTS for a period of a month, or I'm sorry, for a year. In an active LTS, you still get everything but the breaking changes that land on the current release line. But we keep them in current for a few weeks to make sure that they're stable and there aren't any major regressions. And then we start backporting them. So you get the same changes, but just at a slower pace and kind of with an increased guarantee around stability. After those 12 months, even-numbered releases go into maintenance mode for a period of 18 months. So this is to give ample time for large enterprises and whatnot to migrate to the next, whatever the next release line they're going to target is. So this is kind of an overview of all of the release lines right now. Next I wanted to go and dive into each individual release line in a little more detail and see what's going on there. So Node 14 is currently in maintenance mode. It goes by the codename Firmium. So all of the LTS releases get assigned a periodic table element. So Firmium in this case. I think we started with Argon and Node 4, Boron and Node 6, and so on and so on. Some letters don't have periodic table elements. In that case, we just kind of make some up. That's just a fun fact. But so back to Node 14, it will be end of life at the end of April. So you can probably expect one, maybe two more releases between now and then. But if you're using Node 14, you really need to start migrating off now. And I would recommend aiming for Node 18 if possible. And the reason for that is Node 16 is also going to be end of life this year. So Node 16 is known by the Gallium codename. It should have been end of life in April of 2024, but it's only going to be supported until September of 2023. So that is a seven-month difference. But there is a good reason for it. So the version of OpenSSL that ships with Node 16 is also going to be end of life. So as a project, we had to balance, do we want to keep supporting Node 16 just because, or let it go away instead of asking people to run with what could be a possibly insecure version of OpenSSL by the time it hit end of life. So I have linked to the official blog post at the bottom of the slide here if you want more details. But in general, I would just recommend if you're migrating off of Node 14, don't go to 16. If you're currently on 16, start targeting Node 18. So next I wanted to talk about Node 18 briefly. Node 18 goes by the hydrogen codename. It's currently an active LTS and it will go into maintenance in October of this year. And then once it's in maintenance, it'll be supported with security patches and things like that until April of 2025. Node 18 is very stable at this point, and it actually has a lot of features that are not in Node 14 and 16. And personally, this is what I would recommend running in production. This is what I'm using in production at work. Like I said, very stable and definitely what you want to be targeting now. Now there will be people always who want to use the latest and greatest things in production. So that would be Node 19 at this point. Node 19 does not have a periodic table element codename because it's never going to be LTS. It was originally released in October of 2022. It's going to continue being the current release line through April of 2023. At that point, it will have a few months of maintenance support and go end of life in June of 2023. As I mentioned, it will not enter active LTS, and I do not recommend using this in production. In the past, we actually had a lot of instances where the current release line would have regressions that didn't make it back into LTS. That's not so much the case anymore. It's the odd number of releases seem to be getting increasingly more stable, which is good, but I still wouldn't recommend it for production. There is one big notable change in this release line, and that is that D-trace, SystemTap, and ETW diagnostic probes were all removed. The reason for that is simply that Node is an open source project run mostly by volunteers. Nobody was volunteering or stepping up to maintain those bits of code, so they were becoming a maintenance burden, and they've been removed. There is an open issue inviting anybody who feels strongly about these things to come and support them again, but as for right now, they are not currently in the code base. Similar to the graph that I showed at the very beginning, this is a breakdown of downloads by different Node release lines over the past two years. The blue bar, which starts at the far left and then drops off as time goes on, is Node 14. That's the expected behavior and what we want to see. Downloads were increasing, and then it moved into maintenance mode, and they start to drop off. Similarly, Node 16, which is the orange bar, is still in the process of going up and to the right. I'm hoping that people, and it kind of looks like the trend is already starting in this graph, that people will start migrating off of 16 and onto Node 18. Node 15 and 17 are not shown on this graph because they had already reached end of life by the time that this chart was put together. Then you can see the yellow line of Node 18 starting to pick up a little over halfway through the graph. It's slowly picking up steam. Like I said, if we redo this graph in a few months, I imagine that Node 18 will be substantially higher, hopefully more than Node 16. Then the little piece of green at the very far right is Node 19. You can see it came into the world later than all of the other release lines. It hasn't picked up as much traction, and hopefully we'll see it start to also die off. If you wanted to pick what version to run in production, I've already hinted at this, but you should be definitely running an LTS version in production, especially if Node is mission critical. If you're making money off of node.js in production, then you want to be as stable as possible. You also need to ask yourself if you can update easily and frequently. Being on the bleeding edge implies that there could be blood. If you're insisting on running Node 19 in production, make sure that you're able to update easily, because things move a lot faster there. Then you actually have to ask yourself if you really need all the newest features. Some people actually do, but oftentimes the answer is no, you don't strictly need the newest things, and you can wait a few months. These are just recommendations. You can do whatever you want to do, but this is how I would recommend proceeding. Next, I wanted to talk about some of the new features that have made their way into Node via the V8 project. The way things work is when there's a new javascript feature, tc39 creates a specification for it. Browser or javascript engine implementers like V8 will actually build out the new features, and then once node.js upgrades to a version of V8 that includes those features, then we receive the features just by default. One thing that we did have to add some custom logic around in Node is enabling shadow realms. Shadow realms are the language's official solution to things like Node's VM module, so you can run code off in its own realm, send inputs in, get inputs out. It's like VM, it's a little safer than Eval, but because it's still behind an experimental flag in V8, we had to add an experimental flag in Node to unlock those features. We also have a couple new methods on arrays, so findLast and findLastIndex are similar to find and findIndex. They just start from the back of the array instead of the front. There's been a number of api additions and improvements. If you're using the internationalization APIs, so locale has been improved, and then the number format and supported values of method have also been added. There have also been some performance improvements related to class fields and methods. Typically when new features are added to V8, they're not fully optimized, so class fields and methods landed in V8. We had access to them in Node, but we still avoided using them because they were slower than alternatives using things like symbols and whatnot. But the performance there has improved, and we can fully recommend actually using those in your code now. Then a big thing that has recently come is the javascript promise integration, and this is specifically targeting people using webassembly. The way things have generally worked is you call from your javascript code into webassembly, and the webassembly would do some synchronous operations. If it needed some custom functionality, you could call back into javascript, but there was no real way to have asynchronous integration between javascript and webassembly. With so many of the new javascript APIs being promise-based or just asynchronous in general, there was a disconnect there, so this is actually a huge quality of life improvement for people who are using webassembly in Node. Next I wanted to just highlight a few of the APIs that we've gotten based on web platform compatibility. Node does try to support, where it makes sense, a lot of the same APIs that you can get in a browser. A big one that people wanted for years was Fetch. The project did finally make Fetch happen. Along with Fetch came a lot of other APIs like Request and Response and FormData. We have WebStreams, which are the browser's response to node.js streams. Right now they're not highly optimized in Node, but they're improving a little bit at a time. We have WebCrypto, Structured Clone, which is really nice for being able to copy objects. I'm not going to list all of the different things here, but we are constantly trying to improve our compatibility with the web platform. Another big feature that landed in Node 18 is a built-in test runner. There are a few ways to use the test runner. There's the node colon test module inside of Core that you can require. There's also a CLI runner, which is enabled with dash dash test. If you're using an older version of Node that this hasn't been ported to, like right now Node 14 does not have support for it, some time people were nice enough to take the code from Core, put it into a package on npm, and you can actually install it from there and get almost all the same functionality. It supports a lot of the things that you would expect a test runner to support out of the box. It has subtests, it can skip over tests, you can specify only tests, so you only want to run a subset of your test suite, lifecycle hooks such as before, before each, after, and after each, and things like that. It does also support mocking out of the box. It doesn't currently support mocking of entire modules because there are some limitations around ES modules there, but you can mock functions, methods, and things like that. It does have built-in code coverage out of the box, which you can enable with the dash dash experimental test coverage CLI flag. You can now also write your own custom reporters. There are a few that are built into Node. By default, it's going to be TAP, which stands for the Test Anything Protocol, which is a format for expressing test results, which is used among other ecosystems, not just node.js. That's going to be sent over standard out, but you can customize it. You can use SPEC, which is a more human-readable format, TAP, the little format where it just shows dots with Xs. I don't know what the name of that is. And then you can use the test reporter destination flag, where you can actually say where you want your results to be sent to. As I said, by default, it's standard out, but you can use standard error and other things. This is just a quick picture of what a test looks like. We support synchronous tests, asynchronous tests, callbacks, etc. On the left here is what you would get if you ran the previous test and generated TAP output. On the right is what you get with the SPEC reporter. If you wanted colors and things that are a little more human-friendly, you could use that. From the test runner also came another new feature called Node Prefix Only Core modules. The difference here, if you look at the top, we're importing the node colon test and node colon assert. Every core module can be imported using the node colon prefix, and that's nice because it lets tools and people reading the code know right off the bat when something is a core module. At the bottom here, you can also import the assert module and all the other core modules without the node prefix, but with the test runner and probably with all future core modules, that's not the case. Node test will get you the core module. Test will try to load from user land, so node modules and things like that. It is an important distinction to be aware of, especially moving forward as there are potentially going to be more core modules that follow this pattern. We also have a watch mode now. It's very similar to NodeMon. If you've used that, dash dash watch command line flag, it will watch all of your imported files and when any of those change, it'll restart node. It is integrated with the test runner, so you can run your tests, change some things, and then it will rerun your tests for you. You can customize with the dash dash watch path flag which files you actually want to watch, although this is limited to Mac OS and Windows. There's also util.parseargs. This is a simple api for parsing command line flags and giving them back in a data structure. This is actually going to be stabilized in Node 20, so it's just something to be familiar with. One less thing you have to rely on npm for. Very recently, we landed support for single executable applications. This allows you to inject your application code into a node.js binary, and then you can distribute that binary to systems that don't have Node or npm installed on them. Currently, only a single common JS file is supported, but you can use a bundler or something like that to create that common JS file and then bundle your whole application that way. The Node project does have a helper module for this called postject, which is available on npm. It was kindly donated by the people at Postman Labs. There are similar tools out there that exist, but the project doesn't officially test any of those. We also just very recently landed a permission system, so you would enable it with dash dash experimental permission. Once that is enabled, it locks down access to the file system, child processes, and markers. And then there are various flags here below that you can use to unlock all or portions of those things. Wildcards are supported, so you can say allow FS read star, and that will allow you to read anything from the file system. You can also use the programmatic api inside of your code, so process.permission.has. You can check if you have a specific permission, and then you can deny additional things at runtime. There is no way to then re-allow them. That makes sense because you wouldn't want to allow people to give themselves more permissions. But so you can always check what permissions you currently have, and it can be a little more granular. So you can see here we've disabled file system rights to a particular directory. We still do have overall file system right access, but not to that specific directory, is what this example is conveying. There have been some other notable changes recently, happy eyeball support, which will allow you to do DNS resolution with IPv4 and v6 at the same time. Streams helpers to go back and forth between node streams and web streams and things like that. I'm not going to name all of them, again, in the interest of time. One thing worth pointing out is we did have snapshot testing via assert.snapshot, but people weren't really happy with the implementation, so we've removed that and hoping to revisit it to refine it a little bit more. Some potential upcoming features. Just recently there was a pull request open to add foreign function interface, or FFI, to core. People are currently working on solutions for better typescript integration, QUIC, building in proxy support to fetch, and hopefully promise-fying some more of the core modules. There are only a few left at this point. Again, these are all upcoming things that may or may not happen, so I think that they'll probably happen, but I don't want to make any promises that I can't keep. And then lastly, I wanted to touch on some of the important links around the project. So if you have a bug report or a feature request, go to nodejs.node on GitHub. A support question, you can either create a discussion or go to If you're curious about the release schedule, some of the things I talked about earlier in this talk, nodejs.release has all of those details. If you have a security vulnerability that you found, please report it on HackerOne with the link here. Don't report it on the public issue tracker. And then finally, nodejs is active on the OpenJS Foundation Slack, so there's a link here where you can join the Slack. NodeJS and nodejs.core are the big channels there where the project is kind of discussed. And that's everything from me. Just real quick, I wanted to take a shameless plug to the company I'm currently working for, Platformatic, which is helping to make api creation with node.js a lot simpler for REST APIs, graphql, metrics, all the things that are kind of undifferentiated, heavy lifting, we're trying to make simpler for everyone. And that is all I have. Thanks again for coming to my talk. I'm going to go ahead and close this out.
24 min
18 Apr, 2023

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Workshops on related topic