14
inaba
6y

So I'm making a file uploader for a buddy of mine and I got an error that I had never seen before. Suddenly I had C++ code and some other weird shite in my terminal. Turns our that I got a memory leak and the first thing that sprung to mind was "Fuck yes, I get to do some NCIS ass debugging".

Now the app worked fine for smaller files, like 5MB - 10MB files, but when I tried with some Linux ISO's it would produce the memory leak.

Well I opened the app with --inspect and set some breakpoints and after setting some breakpoints I found it. Now, for this app I needed to do some things if the user uploads an already existing file. Now to do that I decided to take the SHA string of the file and store it in a database. To do this I used fs.readFile aaaaaaaaaand this is where it went wrong. fs.readFile doesn't read the file as a stream.

Well when I found that, boy did I feel stupid :v

Comments
  • 2
    But at least, now you know 👍😃
  • 2
    Don't feel bad.
    Many file operations differ between versions of Node, especially checking if a file exists. I don't think that one has ever remained unchanged.
  • 0
    @karma learning like this is the best 😊

    @Root yeah but still, I feel a bit silly :p
  • 0
    Congratulations, you successfully breached the first of 9 NCIS main frame firewalls.

    Yes. I do remember this NCIS episode where the NCIS chief was led by the NCIS hackerman to prevent the NCIS from being hacked by a botnet.
    A countdown had shown the remaining time till every bit of data would be erased forever since there is no backup system.

    xD
  • 0
    @Brosyl
    Wow, what an awesome reply!
    Thanks for your time, dude.

    Yeah. Kind of.
    But as they claimed that there was not a single byte manipulated, because of the most heroic act of the glorious NCIS team.

    Damn! These guys are one of a kind ^^
Add Comment