14

Hit an issue in a dependency of the node library I use, there's been many issue reports on it since october last year and multiple recently (12 days and 4 days ago) - the fix was a one-liner.

All you had to do was check for null in line 17, because in line 9 it gets defaulted to null, but then attempts to null.fetch() in line 21.

Fascinating.

Comments
  • 1
    Name the library
  • 1
    @inaba dompurify that has the server-side dependency jsdom in question
  • 3
    @JoshBent null is evil.

    Either/Maybe is love!

    (Check Folktale's Maybe for a beginner-friendly implementation and docs. Sanctuary for safety and beardness)
  • 1
    How this thing even gonna work? Fetch is an async func, but the code try to return immediately?
    Am I missing something?
    BTW just return is fine. I mean return undefined. Return null feels like it executed something, and the result is null.
  • 1
    if(!this._document)
  • 0
    @sunfishcc I purely extended on what was there already, as you see couple lines down the devs return "null", so I just did the same and it works. I really don't have the time to see why a null returned works and improve on it.
  • 0
    @AlgoRythm there's a lot of missing null checks throughout I've spotted while just skimming, but I am really too busy to fix their entire codebase, this should fix the issue most had, incl. me, so I can continue everything else that builds on top of it.

    Also: how do you know if a bug exists? if the users create issues - otherwise there's none ;)
  • 1
    @JoshBent start a pull request maybe you will get some swag from them 👍
  • 2
    @sunfishcc did already, especially because so many struggle with it, not for the swag. The dev seems to be MIA though, so who knows when that'll get any review.
  • 1
    @JoshBent Ah, so I see... Users create bugs! Those fuckers!
  • 1
    @JoshBent oh jeez. Maybe just create a new private package based on their code.
  • 1
    @sunfishcc for now I just have my dockerfile copy the file in after it npm installs, but if there's going to be more I will most definitely create a private repo for it
Add Comment