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

Rework forge command invocation (broken EPIPE issue) #642

Open
wants to merge 8 commits into
base: development
Choose a base branch
from

Conversation

antico5
Copy link
Collaborator

@antico5 antico5 commented Feb 24, 2025

This PR changes the handling of the child process spawned when running forge, currently only used for formatting. The broken EPIPE error happens when a process tries to write to the stdin of a dead process.

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 18.75000% with 39 lines in your changes missing coverage. Please review.

Project coverage is 54.32%. Comparing base (e5372f3) to head (09a4470).

Files with missing lines Patch % Lines
server/src/utils/operatingSystem.ts 8.69% 21 Missing ⚠️
server/src/services/formatting/forgeFormat.ts 27.27% 8 Missing ⚠️
...er/src/services/formatting/onDocumentFormatting.ts 14.28% 6 Missing ⚠️
...rver/src/frameworks/Foundry/resolveForgeCommand.ts 33.33% 2 Missing ⚠️
server/src/utils/errors.ts 50.00% 2 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #642      +/-   ##
===============================================
- Coverage        54.52%   54.32%   -0.21%     
===============================================
  Files              226      227       +1     
  Lines             5199     5230      +31     
  Branches           800      809       +9     
===============================================
+ Hits              2835     2841       +6     
- Misses            2127     2152      +25     
  Partials           237      237              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@antico5 antico5 requested a review from kanej February 24, 2025 18:35
@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Feb 24, 2025
Copy link
Member

@kanej kanej left a comment

Choose a reason for hiding this comment

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

I think we need to clear the timeout on process exit.
I am tempted to say we should rework the timeout Error, so that when it is caught by the try/catch in onDocumentFormatting we report a more specific sentry status for timeout: { status: "internal_error", result: null }. This would let us separate out timeouts from anything else.

@kanej
Copy link
Member

kanej commented Feb 26, 2025

As a sidepoint - the codecov here is really painful to review. If it is not pulling its weight we should consider turning it off.
What do you think would be required to bring execWithInput under test?

@antico5 antico5 requested a review from kanej February 26, 2025 14:44
@antico5
Copy link
Collaborator Author

antico5 commented Feb 26, 2025

@kanej addressed all comments. About codecov, I'd be happy to remove it. We can tell on PR reviews what needs and what doesn't need coverage. For execWithInput, I think it's not viable to unit test. It would involve a lot of stubbing and mocking, and the added value would be almost nonexistent. For a non-stub testing case, we'd have to see what's possible in terms of process manipulation from our test case, and it can be tricky to have it be multi platform.

antico5 and others added 3 commits March 11, 2025 15:46
The type narrowing wasn't working on the version of typescript we build
with. I added a typeguard to circumvent the build problem.

return [textEdit];
function isKilledDefinedExecException(error: unknown): error is ExecException {
Copy link
Member

Choose a reason for hiding this comment

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

My previous suggestion caused a build error. So this type guard, while cumbersome does the job. We should port the error helpers from Hardhat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants