AzureStorageExplorer icon indicating copy to clipboard operation
AzureStorageExplorer copied to clipboard

Formatting JSON in preview isn't working

Open craxal opened this issue 1 year ago • 7 comments

Preflight Checklist

Storage Explorer Version

1.36.0

Regression From

1.35

Architecture

x64

Storage Explorer Build Number

20241012.1

Platform

All

OS Version

Windows 11

Bug Description

Formatting json files no longer works, it changes but then reverts back to unformatted json.

Steps to Reproduce

  1. Launch storage explorer
  2. Open blob storage container
  3. Preview unformatted json file
  4. right-click select "Format JSON"
  5. Close just opened tab

Actual Experience

When selecting the "Format JSON" option, the formatted json is displayed for a brief moment, before reverting back to unformatted json.

Expected Experience

I would expect the formatted json to be displayed.

Additional Context

No response

craxal avatar Oct 18 '24 20:10 craxal

@houlgap Just to get some details, how long is this brief moment? I assume this happens for every JSON file you try? Do you have app logs you can share?

craxal avatar Oct 18 '24 20:10 craxal

The formatted json is displayed for a fraction of a second, and it happens for every json file I have attempted so far. Here is a video of the repro https://github.com/user-attachments/assets/63e5ffb3-e98a-47e9-8103-f00e17b07a79

Is there a secure way to upload the logs? I have reviewed them but they don't seem to capture anything relevant to this issue.

houlgap avatar Oct 21 '24 15:10 houlgap

@houlgap Sensitive information is redacted automatically from the logs, so you can share them safely here. If you're still concerned, you can share them privately by sending them to sehelp at microsoft dot com.

craxal avatar Oct 21 '24 16:10 craxal

I am also able to reproduce this. I've also noticed the "Format JSON" command does not change to "Restore JSON", so something is causing it to revert back immediately.

craxal avatar Oct 21 '24 16:10 craxal

See trace logs attached StorageExplorerLogs.zip

houlgap avatar Oct 21 '24 17:10 houlgap

Problem seems to have started after commit 2711461 when tab lifecycle was introduced. No idea why this would affect the Monaco editor....

I believe this has the same root cause as #8235.

craxal avatar Oct 21 '24 18:10 craxal

We've discovered the problem. Code that sets up the <webview> element is run in the update method of a custom Knockout binding. Formatting JSON modifies the display name of the tab. Since the display name of the tab is an observable, the update method runs again, which means the setup code is run again, ultimately creating a new <webview> renderer process. This is why the JSON appears to reset almost immediately and why a crash happens when trying to close the tab.

This feels serious enough for a hotfix, so you should see a fix in 1.36.1 soon.

craxal avatar Oct 22 '24 17:10 craxal