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: fuels dev hangs after compilation errors #3504

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Dhaiwat10
Copy link
Member

@Dhaiwat10 Dhaiwat10 commented Dec 26, 2024

Release notes

In this release, we:

  • Fixed a bug where fuels dev would hang after a Sway compilation error

Summary

This PR fixes the issue where fuels dev would hang after a Sway compilation error. The build process was failing and the failure was caught, but the reject callback that is called on failure was being called with an error code 1, which can't be rethrown later once the reject's error is caught in a try/catch - it has to be an Error object. After changing it to an Error(forc exited with exit code ${code}), I realized that the error handlers present in those try/catches weren't re-throwing the caught error. After adding a re-throw in them, I found out that the error was further being swallowed in the bin.ts file. The bug was fixed upon changing that.

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

Copy link

vercel bot commented Dec 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 4:44pm
ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 4:44pm
ts-docs-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 4:44pm

Copy link
Contributor

github-actions bot commented Dec 26, 2024

This PR is published in NPM with version 0.0.0-pr-3504-20250102160454

@Dhaiwat10 Dhaiwat10 marked this pull request as ready for review December 26, 2024 17:11
.changeset/silly-pianos-fry.md Outdated Show resolved Hide resolved
packages/fuels/src/cli/commands/withConfig.test.ts Outdated Show resolved Hide resolved
packages/fuels/src/cli/commands/withConfig.test.ts Outdated Show resolved Hide resolved
nedsalk and others added 2 commits January 10, 2025 15:15
Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
@nedsalk nedsalk requested a review from arboleya January 12, 2025 12:53
error(err.message);
if (config) {
await config.onFailure?.(config, <Error>err);
Copy link
Member

Choose a reason for hiding this comment

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

Why go from async to sync?

Copy link
Contributor

@nedsalk nedsalk Jan 13, 2025

Choose a reason for hiding this comment

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

It was always sync because onFailure returns void. ref

We could change the signature to be Promise<void> | void in some other PR - it comes in handy to be able to pass async callbacks.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. I think we could then fix the return type (still in this PR) and keep it async because the user may have an async tear-down routine for these failure scenarios, and if we don't wait, things may be left dirty.

If we leave types aside for one second, we'd be doing something similar to what we did with the test utilities for asserting Fuel errors, although this case is much less convoluted. By considering it could always be async and always awaiting for it, we cover both cases.

Copy link
Contributor

@nedsalk nedsalk Jan 13, 2025

Choose a reason for hiding this comment

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

I have reverted withConfigErrorHandler to be async again in 7c333c9, as well as all of the other related changes like this await, and have created #3582 because all our event listeners are synchronous. I have included this onFailure listener there as well. I think it's better to cover it all in one PR for that issue. Sounds good?

Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
77.01%(-0.01%) 70.55%(-0.06%) 75.13%(+0%) 77.02%(-0.01%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 packages/account/src/providers/transaction-request/transaction-request.ts 88.57%
(+0%)
76.71%
(-1.37%)
84%
(+0%)
88.81%
(+0%)
🔴 packages/fuels/src/cli/commands/withConfig.ts 92.85%
(-7.15%)
100%
(+0%)
100%
(+0%)
92.85%
(-7.15%)

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

Successfully merging this pull request may close these issues.

Command fuels dev hangs on generating types
4 participants