fix,v8: make `v8.writeHeapSnapshot` throw if `fopen`/`fclose` fail
Fixes: #41346 (closed)
Alternative to #41365, this PR makes v8.writeHeapSnapshot
throw if the file could not be written, which can happen inside read-only directories (such as those from Docker containers).
I was not able to make a readonly directory on Windows since I could still write new files to it (is it even possible on Windows?), so I created an empty readonly file instead and made the function attempt to write on it. I ran this function in both Node.js 16.13.1 and the test fails as intended.