Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

zermelo-wisen
Copy link
Contributor

Fixes #70

Copy link
Collaborator

@dividedmind dividedmind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure errors are reported instead of being silently swallowed. Easiest way to do this is probably to spin out an async function instead of using the callback flavor of readFile. (Node will show an error message when an exception is thrown in a promise but not caught, which is good enough IMO.)

@zermelo-wisen
Copy link
Contributor Author

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
Copy link
Collaborator

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();
        }

@zermelo-wisen zermelo-wisen force-pushed the fix/dont-block-in-remote-recording-finish branch from 71abda1 to 26e702d Compare April 23, 2024 06:15
@zermelo-wisen zermelo-wisen force-pushed the fix/dont-block-in-remote-recording-finish branch from 26e702d to 55476fa Compare April 24, 2024 14:27
@zermelo-wisen zermelo-wisen force-pushed the fix/dont-block-in-remote-recording-finish branch from 55476fa to a6a5837 Compare April 24, 2024 20:56
@dustinbyrne dustinbyrne merged commit 40bcd0c into main Jul 23, 2024
6 checks passed
@dustinbyrne dustinbyrne deleted the fix/dont-block-in-remote-recording-finish branch July 23, 2024 13:07
@appland-release
Copy link

🎉 This PR is included in version 2.23.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I’m curious why we block here
4 participants