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

"Error: DocHandle is not ready" with useBootstrap #266

Open
neftaly opened this issue Jan 2, 2024 · 3 comments
Open

"Error: DocHandle is not ready" with useBootstrap #266

neftaly opened this issue Jan 2, 2024 · 3 comments

Comments

@neftaly
Copy link
Collaborator

neftaly commented Jan 2, 2024

I encountered a sharp edge building a simple useBootstrap app. I must have initialized useBootstrap with an empty or broken onNoDocument function, which resulted in the document ID being saved to localstorage, but the document itself not being created.

Whenever I tried to write anything, I got the following console.error:
Uncaught Error: DocHandle#... is not ready. Check `handle.isReady()` before accessing the document.

It was not immediately obvious what was happening, and the error persisted between reloads. I have encountered this before and would like it to be easier to diagnose for someone unfamiliar with the library.

  • The error message could provide a link to a documentation page with more information?
  • The chrome devtools could log a message like "useBootstrap: loading existing documentId from localstorage"?
@neftaly
Copy link
Collaborator Author

neftaly commented Jan 2, 2024

For anyone encountering this error, what is happening is that automerge-repo is waiting for a peer to share the document (which won't happen as it doesn't exist). The solution is to delete the automergeUrl key from localstorage and the hash URL, or to change useBootstrap.key to something different.

@neftaly
Copy link
Collaborator Author

neftaly commented Jan 2, 2024

A simple way to recreate this is to use useBootstrap without a repo storage adapter. This should be a supported use-case (I don't want persistent storage while I'm testing things).

@neftaly
Copy link
Collaborator Author

neftaly commented Jan 10, 2024

I think a documentation page would be the best bet, with advice on disabling storage/hashurls for development.

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

No branches or pull requests

1 participant