Transcript
March 22nd, 2016. Builds at companies around the world started failing, hundreds every minute. The cause was 11 lines of code. And they had just been deleted. Those lines lived on npm, a giant warehouse of free JavaScript code. Each box of code in it is called a package. When you build an app, a tool fetches every package it needs, and every package those packages need. One app can pull in hundreds you never chose. One of them was left-pad. It does one small job: it adds spaces or zeros to the left of text, so 5 becomes 005. It was downloaded about 2.5 million times that month. So how did it vanish? Its author also had a package called kik. A messaging company, also named Kik, wanted that name. npm gave it to them. In protest, the author removed all 273 of his packages. Left-pad was one of them. Now follow the chain. Babel, a popular tool for building JavaScript, used a package called line-numbers. And line-numbers asked for left-pad, exactly version 0.0.3. The registry answered: 404, not found. The whole build stopped. Within ten minutes, another developer published a copy, as version 1.0.0. It didn't help. The chain still asked for 0.0.3. So npm did something it had never done. It restored 0.0.3 from a backup. After about 2.5 hours, builds went green again. Then npm changed the rules. After 24 hours, you can't simply unpublish a package if other projects depend on it. Teams also pin exact versions in lock files, and many keep their own copy of every package. And in 2017, JavaScript got padStart built in. So remember it like this: your app is only as solid as the smallest box at the bottom of the stack. Want to practise real-world IT, hands-on? Try it free at seclern.com, and follow for more.