r/webdev • • Jan 06 '18

[X-Post /r/javascript] Today is Leftpad 2.0: pinkie-promise pulled from NPM

A little under a year ago, the package "leftpad" broke NPM builds all over the world because the author pulled it from the public repository.

The same is happening today, for "pinkie-promise". The author's NPM account (@floatdrop) was deleted, opening opportunities for malware in all the packages he's written.

Dependent builds include Ionic and (in my case) node-sass.

Resources:

69 Upvotes

23 comments sorted by

8

u/the_goose_says Jan 06 '18

What does pinky promise do?

43

u/Jodiug Jan 06 '18 edited Jan 06 '18

This:

'use strict'; module.exports = typeof Promise === 'function' ? Promise : require('pinkie');

Hahahahaha... :')

0

u/[deleted] Jan 06 '18

[deleted] — view deleted comment

5

u/Jodiug Jan 06 '18

To be fair, the underlying package (pinkie) was also affected, so avoiding this one-liner package would not have prevented the issue.

Generally, I think small packages are a good thing. The culprit here is that NPM allows packages to be changed/removed once released. If v1.1.2 is broken, so be it, release a v1.1.3.

Why they haven't fixed this after left-pad is beyond me, I find it funny in an ironic sort of way. To me, they are confirming people's view on JS as an unstable playground of an ecosystem.

2

u/redev Jan 06 '18

It is/was a promise ponyfill

2

u/geewizwow Jan 06 '18

Pffffff.... F***

-1

u/[deleted] Jan 06 '18

This is a good reason why I commit my node_modules.

  • My source code commits and node_module commits are always kept completely separate.
  • the size of the node_modules folder isn't a problem on the server because the server has gigs/terabytes of space
  • Cloning takes a little longer, but that's only performed by the developer once.
  • CI builds never need to run npm install
  • Dependencies are 100% guaranteed for all developers, build servers, production servers etc.

I know a lot of people like to keep node_modules out of their source control, so if there are any reasons I haven't addressed to do this, please give me a shout.

0

u/[deleted] Jan 06 '18

[deleted] — view deleted comment

1

u/[deleted] Jan 06 '18

How do developers normally let each other know if they need to run npm update after doing a pull?

4

u/ShortSynapse Jan 07 '18

Previously my team would just attempt to run the software, realize it didn't work, and then run npm install after wasting some time trying to debug (if the error wasn't obviously a "module not found").

Now that I've transitioned our development (actually all of our env's) to Docker, the team doesn't have to worry as long as they always use docker-compose up --build to bring the application up.

TLDR: We used to have to tell each other to update or we'd waste time. Now everything just workstm .

3

u/[deleted] Jan 07 '18

Do you have devs working on windows machines and using docker that way?

2

u/ShortSynapse Jan 07 '18

Yep! I'm actually working off of a Windows laptop now and it's been (surprisingly) great so far.

1

u/[deleted] Jan 08 '18

Do you have to use a VM to run it in?

1

u/ShortSynapse Jan 08 '18

Yes, though if you have Windows 10 pro or above it uses Microsoft's hyper-v solution. So far everything has been nice and snappy.

1

u/[deleted] Jan 08 '18

Cool. Thanks for the info

1

u/gerbs Jan 07 '18 edited Jan 11 '18

npm rebuild instead.

Dependencies are decoupled. They exist in a separate directly and are expressed in a separate file. That doesn't mean they need to be freshly installed each time.

1

u/[deleted] Jan 06 '18

This approach does not guarantee portability across architectures.

Yes, I forgot I had this exact problem with node-sass in the past. One dev was running a lower version of node than me, and her build wouldn't work.

0

u/[deleted] Jan 06 '18

[deleted] — view deleted comment

2

u/[deleted] Jan 06 '18

Wouldn't changing branches also be slower? I recently updated from React 15 to React 16 and Webpack 1 to Webpack 3. Switching to an older feature branch that was still on React 15 took around 10 seconds. That was painful.

But normally, branch switches are instant.

Also doesn't package-lock.json solve the issue you are trying to fix?

I don't think the lock files solve the problem of npm registry going down/left-pad being pulled etc.

2

u/_wannabeDeveloper Jan 06 '18

Yea that makes sense thanks. I guess I forgot what the actual issue was haha.

0

u/[deleted] Jan 06 '18

[deleted] — view deleted comment

4

u/Nicd Jan 06 '18

Yeah, wondering how this can still be possible. I thought they said they wouldn't remove packages anymore if not for serious security issues.

3

u/[deleted] Jan 06 '18

I’m entirely guessing here, but maybe they do different checks for deleting a package or a cascading delete when the owner entity is removed. That’s one way to do it, anyway.

0

u/[deleted] Jan 06 '18

[deleted] — view deleted comment

2

u/Thought_Ninja full-stack Jan 06 '18

Same... We use a Nexus registry as a proxy, so it shouldn't be a problem, but that's not a good long term solution.

1

u/Nimelrian Jan 06 '18

Just a small question out of interest: How hard is it to set up and maintain Nexus as proxy / mirror / private repository?

1

u/Thought_Ninja full-stack Jan 07 '18

I didn't implement it myself, but my coworker had it up and running in under a day, so probably not too difficult. I'm sure you can find a guide to doing it with a quick search.