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

Opening custom document in text editor erases document #216

Open
agupta01 opened this issue Jan 24, 2023 · 2 comments
Open

Opening custom document in text editor erases document #216

agupta01 opened this issue Jan 24, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@agupta01
Copy link

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:

Screen.Recording.2023-01-23.at.4.39.24.PM.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 agupta01 added the bug Something isn't working label Jan 24, 2023
@welcome
Copy link

welcome bot commented Jan 24, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@fcollonval
Copy link
Member

Thanks for reporting @agupta01

The upcoming 3.6.0 (3.6.0rc0 is released) has seen lots of improvements on the RTC side (:warning: some API has changed - see the migration guide).

That said (and putting aside the blank state that is definitely a bug) opening the same file with two different shared models is for now dangerous or at least unstable. The trouble is that you will end up having two different in-memory models that do not interact except if they see the file changes on disk.

cc @hbcarlos that could provide more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants