extension-examples icon indicating copy to clipboard operation
extension-examples copied to clipboard

Opening custom document in text editor erases document

Open agupta01 opened this issue 2 years ago • 2 comments

Description

When using the shared document example and opening the document using the standard text editor ("Editor"), the window is blank. Then, when reopening the file using the extension editor, it throws a JSON parse error indicating the file is now blank.

Reproduce

  1. Start the documents example
  2. Outside of jupyterlab, open the testfiles/test.example file to confirm it is not empty.
  3. Click on testfiles, and then test.example to open it using the example widget. Confirm you can see a blue box with the text "Hello YJS!"
  4. Right-click on test.example to open the context menu, then click on "Open With" > "Editor" to open it in the standard text editor. Notice how the opened widget does not show anything.
  5. Close both open editors, and re-open test.example by double-clicking on it to use the example widget
  6. You should get a "File load error for test.example" error.
  7. Go back into your system's finder/file explorer and open the test.example file in a non-jupyter viewer. You will see that it is now blank.

See the below video for full reproduction:

https://user-images.githubusercontent.com/12228572/214187127-06bef00d-38e5-45a4-9e19-0a3653a7e8c9.mov

It looks like there is a ServerApp log that is produced right after the text editor is opened that saves test.example (see logs for more context):

[I 2023-01-23 16:49:58.917 ServerApp] Saving file at /testfiles/test.example

Perhaps this call is erroneous and the reason why the file is being cleared when the text editor is opened?

Expected behavior

When the file is opened using the standard text editor, it should display the following:

{
  "x": 177,
  "y": 301,
  "content": "Hello YJS!"
}

Context

  • Operating System and version: MacOS Monterey 12.5.1
  • Browser and version: Firefox 109
  • JupyterLab version: 3.5.0

Note: All paths sanitized with $USER where applicable

Troubleshoot Output GitHub said this was too long, so here's the pastebin: https://pastebin.com/EFFL90R2
Command Line Output Pastebin: https://pastebin.com/nfV0ppVV
Browser Output
Some cookies are misusing the recommended “SameSite“ attribute 75
Starting application in workspace: "default" [jlab_core.e37d4bbc8c984154bc26.js:2:5779](http://localhost:8890/static/lab/jlab_core.e37d4bbc8c984154bc26.js?v=e37d4bbc8c984154bc26)
Source map error: Error: request failed with status 404
Resource URL: http://localhost:8890/static/lab/jlab_core.e37d4bbc8c984154bc26.js?v=e37d4bbc8c984154bc26
Source Map URL: jlab_core.e37d4bbc8c984154bc26.js.map?v=e37d4bbc8c984154bc26

Showing error: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data fromString model.js:160 _revert jlab_core.e37d4bbc8c984154bc26.js:2 promise callback*_revert jlab_core.e37d4bbc8c984154bc26.js:2 initialize jlab_core.e37d4bbc8c984154bc26.js:2 d jlab_core.e37d4bbc8c984154bc26.js:2 promise callback*_createOrOpenDocument jlab_core.e37d4bbc8c984154bc26.js:2 open jlab_core.e37d4bbc8c984154bc26.js:2 openOrReveal jlab_core.e37d4bbc8c984154bc26.js:2 handleOpen jlab_core.e37d4bbc8c984154bc26.js:2 evtDblClick jlab_core.e37d4bbc8c984154bc26.js:2 handleEvent jlab_core.e37d4bbc8c984154bc26.js:2 jlab_core.e37d4bbc8c984154bc26.js:2:84153 Failed to initialize the context with 'example-model' for testfiles/test.example SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data fromString model.js:160 _revert jlab_core.e37d4bbc8c984154bc26.js:2 promise callback*_revert jlab_core.e37d4bbc8c984154bc26.js:2 initialize jlab_core.e37d4bbc8c984154bc26.js:2 d jlab_core.e37d4bbc8c984154bc26.js:2 promise callback*_createOrOpenDocument jlab_core.e37d4bbc8c984154bc26.js:2 open jlab_core.e37d4bbc8c984154bc26.js:2 openOrReveal jlab_core.e37d4bbc8c984154bc26.js:2 handleOpen jlab_core.e37d4bbc8c984154bc26.js:2 evtDblClick jlab_core.e37d4bbc8c984154bc26.js:2 handleEvent jlab_core.e37d4bbc8c984154bc26.js:2

agupta01 avatar Jan 24 '23 01:01 agupta01