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

Fixes Rare '<optimized out>' Exception when changing Body Content-Type back to json #780

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

synapsecode
Copy link
Contributor

@synapsecode synapsecode commented Apr 6, 2025

PR Description

While using the application I came across an issue that is a fairly common user-flow.
When adding Json to Body and switching to text and switching back, we get an exception.

This does not happen for all types of JSON but it has happened to me a couple of times. Especially when using JSON from LLMs.

EXCEPTION_VIDEO.mov

Fixes: #782

I identified the source of this issue to this line:

//editor_json.dart
controller.formatJson(sortJson: false);

Adding a 50ms delay fixed this problem and running the same set of steps does not reproduce the error now

After Fix:

FIX_VIDEO.mov

The examples mentioned in the issue are directly copied from the internet/LLMs (which many of our users are going to do).
We cannot expect users to go and manually format their copied json bodies for this to work reliably. Hence I wanted to fix this issue.

My approach has been tested against all these examples and has not reproduced that error again.

Hence, please review & merge this!
Thanks

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

@synapsecode
Copy link
Contributor Author

synapsecode commented Apr 7, 2025

@animator could you please review this issue fix?

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

Successfully merging this pull request may close these issues.

Rare '<optimized out>' Exception after changing Body Content-Type back to json
1 participant