Following link that doesn't exist: hangs, opens a ton of files

What happens:
I have an org file open in my buffer, and it’s in my org-roam directory. If I click/enter-follow on a link that doesn’t exist, like [[id:doesnt_exist][my title]]:

  • A message appears: “Position saved to mark ring, go back with M-x org-mark-ring-goto”
  • emacs hangs
  • a ton of seemingly random files get opened (it appears to be files I have opened recently, but they seem to be exclusively NOT files in my org-roam directory
  • then another message "Cannot find entry with ID “doesnt_exist”

This whole process takes 5-10 seconds

I’m trying to figure out if I have something massively messed up in my configuration or if this is a known issue

Thank you in advance!

What you describe seems like a normal behavior of Org-ID without Org-roam. This would mean that your Org-roam might not be working for the Org file that you are testing. How do you ensure the file is actually in your org-roam-directory? Is your Org-roam working otherwise?

thanks for your reply!

How do you ensure the file is actually in your org-roam-directory?

For the most part I only add an :id: property to files that live in my org-roam-directory. I’m not sure if that makes sense; another way to say it is that every file in my org-roam-directory has an :id: property set, and it’s unique.

Org-roam is working great otherwise; if I add a link like [[id:this_exists][this exists]] in a file (that also lives in org-roam-directory), trying to visit it via enter or clicking works great, and it opens immediately.

I have this weird issue only for links where a file with that ID does not exist.

Maybe that is how it’s supposed to work? I just would have expected that if the node isn’t found, the user would get prompted to create a new node.

Probably, though my Org-roam returns a message instantly without taking the time to look for a file for the ID (it appears to be hanging, but it should be just opening multiple files and going through them to look for the non-existent ID).

Two things I can think of checking:

  1. Variable org-link-parameters
    For the entry of “id”, you should see :follow org-roam-id-open

  2. Does this “hanging” happen if you click on the link twice in a row?
    I am guessing the second time returns quickly.

For the entry of “id”, you should see :follow org-roam-id-open

Yup, that’s what I see

Does this “hanging” happen if you click on the link twice in a row?

Believe it or not, it does! It doesn’t open all those files again (probably because they are already open!) but it does hang

Perhaps I could replace the “:follow org-roam-id-open” part with my own function? That’s probably getting into the weeds and maybe not ideal…

oh it might be worth mentioning that I have over 5,000 org files in my org-roam-directory. Perhaps it’s looking through each one to find that id?

I would have thought it would query the org-roam database instead.

Just a thought

Maybe. I thought org-roam-id-update (or similar name) would update the in-memory hash table to make it faster next time, but apparently that’s not what happens from your observation.

You could have a look at what the follow function does interactively one line by line with edebig-defun. You could look to replace the function so that it would prompt to create a new node, I think :slight_smile: