getappmap / appmap-node

AppMap client agent for Node.js
Other
9 stars 4 forks source link

fix: Don't block with readFileSync in remote recording finish #145

Closed zermelo-wisen closed 1 month ago

zermelo-wisen commented 5 months ago

Fixes #70

zermelo-wisen commented 5 months ago

Actually my first attempt was to make the Proxy trap for emit asynchronous and use fs.promisses version of readFile instead. But I "felt" it won't be correct even if I wasn't able to find an evidence.

dividedmind commented 5 months ago

Actually my first attempt was to make the Proxy trap for emit asynchronous and use fs.promisses version of readFile instead. But I "felt" it won't be correct even if I wasn't able to find an evidence.

Not sure what you mean with proxy trap, but here's roughly what I have in mind:

        if (recording.finish()) {
          res.writeHead(200);
          const { path } = recording;
          void (async () => {
            res.end(await readFile(path));
            await rm(path);
            reset();
          })();
        } else {
          res.writeHead(200).end("{}");
          reset();
        }
appland-release commented 1 month ago

:tada: This PR is included in version 2.23.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: