Skip to content

Rework forge command invocation (broken EPIPE issue)#642

Merged
antico5 merged 8 commits intodevelopmentfrom
fix-epipe-2
Mar 12, 2025
Merged

Rework forge command invocation (broken EPIPE issue)#642
antico5 merged 8 commits intodevelopmentfrom
fix-epipe-2

Conversation

@antico5
Copy link
Contributor

@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.

@codecov
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).
Report is 1 commits behind head on development.

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
Contributor 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
Co-authored-by: John Kane <john@kanej.me>
Co-authored-by: John Kane <john@kanej.me>
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!

@antico5 antico5 merged commit 7da013a into development Mar 12, 2025
8 of 10 checks passed
@antico5 antico5 deleted the fix-epipe-2 branch March 12, 2025 13:00
antico5 added a commit that referenced this pull request Mar 12, 2025
* Rework forge command invocation

* Address PR feedback

* Rework child process handling

* Update server/src/services/formatting/forgeFormat.ts

Co-authored-by: John Kane <john@kanej.me>

* Update server/src/utils/operatingSystem.ts

Co-authored-by: John Kane <john@kanej.me>

* fix: add type guard

The type narrowing wasn't working on the version of typescript we build
with. I added a typeguard to circumvent the build problem.

* chore: switch the codecov check to be informational

* chore: revert the attempted codecov change

---------

Co-authored-by: John Kane <john@kanej.me>
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