Skip to content

Commit 64d9759

Browse files
committed
fixup! test: log error
Signed-off-by: Darshan Sen <[email protected]>
1 parent 4a75f31 commit 64d9759

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

‎src/heap_utils.cc‎

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ void BuildEmbedderGraph(const FunctionCallbackInfo<Value>& args){
220220
namespace{
221221
classFileOutputStream : publicv8::OutputStream{
222222
public:
223-
FileOutputStream(Environment* env, int fd, uv_fs_t* req)
224-
: env_(env), fd_(fd), req_(req){}
223+
FileOutputStream(int fd, uv_fs_t* req) : fd_(fd), req_(req){}
225224

226225
intGetChunkSize() override{
227226
return65536; // big chunks == faster
@@ -230,21 +229,20 @@ class FileOutputStream : public v8::OutputStream{
230229
voidEndOfStream() override{}
231230

232231
WriteResult WriteAsciiChunk(char* data, int size) override{
233-
DCHECK(!aborted_);
232+
DCHECK_EQ(status_, 0);
234233
int offset = 0;
235234
while (offset < size){
236235
uv_buf_t buf = uv_buf_init(data + offset, size - offset);
237-
int num_bytes_written = uv_fs_write(nullptr,
238-
req_,
239-
fd_,
240-
&buf,
241-
1,
242-
-1,
243-
nullptr);
236+
constint num_bytes_written = uv_fs_write(nullptr,
237+
req_,
238+
fd_,
239+
&buf,
240+
1,
241+
-1,
242+
nullptr);
244243
uv_fs_req_cleanup(req_);
245244
if (num_bytes_written < 0){
246-
aborted_ = true;
247-
env_->ThrowErrnoException(-num_bytes_written, "write");
245+
status_ = num_bytes_written;
248246
returnkAbort;
249247
}
250248
DCHECK_LE(num_bytes_written, buf.len);
@@ -254,13 +252,12 @@ class FileOutputStream : public v8::OutputStream{
254252
returnkContinue;
255253
}
256254

257-
boolaborted() const{returnaborted_}
255+
intstatus() const{returnstatus_}
258256

259257
private:
260-
Environment* env_;
261258
int fd_;
262259
uv_fs_t* req_;
263-
bool aborted_ = false;
260+
int status_ = 0;
264261
};
265262

266263
classHeapSnapshotStream : publicAsyncWrap,
@@ -353,29 +350,31 @@ inline void TakeSnapshot(Environment* env, v8::OutputStream* out){
353350

354351
Maybe<void> WriteSnapshot(Environment* env, constchar* filename){
355352
uv_fs_t req;
356-
357-
int fd = uv_fs_open(nullptr,
358-
&req,
359-
filename,
360-
O_WRONLY | O_CREAT | O_TRUNC,
361-
S_IWUSR | S_IRUSR,
362-
nullptr);
353+
int err;
354+
355+
constint fd = uv_fs_open(nullptr,
356+
&req,
357+
filename,
358+
O_WRONLY | O_CREAT | O_TRUNC,
359+
S_IWUSR | S_IRUSR,
360+
nullptr);
363361
uv_fs_req_cleanup(&req);
364-
if (fd < 0){
365-
env->ThrowErrnoException(-fd, "open");
362+
if ((err = fd) < 0){
363+
env->ThrowUVException(err, "open", nullptr, filename);
366364
return Nothing<void>();
367365
}
368366

369-
FileOutputStream stream(env, fd, &req);
367+
FileOutputStream stream(fd, &req);
370368
TakeSnapshot(env, &stream);
371-
if (stream.aborted()){
369+
if ((err = stream.status()) < 0){
370+
env->ThrowUVException(err, "write", nullptr, filename);
372371
return Nothing<void>();
373372
}
374373

375-
interr = uv_fs_close(nullptr, &req, fd, nullptr);
374+
err = uv_fs_close(nullptr, &req, fd, nullptr);
376375
uv_fs_req_cleanup(&req);
377376
if (err < 0){
378-
env->ThrowErrnoException(-err, "close");
377+
env->ThrowUVException(err, "close", nullptr, filename);
379378
return Nothing<void>();
380379
}
381380

‎test/sequential/test-heapdump.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ process.chdir(tmpdir.path);
3030
assert.throws(()=>{
3131
writeHeapSnapshot(directory);
3232
},(e)=>{
33-
console.debug(e);
3433
assert.ok(e,'writeHeapSnapshot should error');
3534
assert.strictEqual(e.code,'EISDIR');
3635
assert.strictEqual(e.syscall,'open');

0 commit comments

Comments
(0)