Still some URL issues on Linux

Steps to reproduce

  1. Open Obsidian using a URL. Even directly (which is my preferred method): obsidian "obsidian:///home/user/notes/my_note.md".

Expected result

I expect Obsidian to open the file, and the command that called it should return a 0 status code.

Actual result

The note indeed opens, but an error is displayed in the terminal, and the command doesn’t return until I kill it. This is a problem for external tools that wish to call Obsidian for opening a file.
This is the error displayed:

(node:782621) UnhandledPromiseRejectionWarning: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
    at doWrite (_stream_writable.js:427:19)
    at writeOrBuffer (_stream_writable.js:415:5)
    at WriteStream.Writable.write (_stream_writable.js:305:11)
    at fn (/tmp/.mount_obsidiGXTsuj/resources/app.asar/main.js:37:10)
    at update (/tmp/.mount_obsidiGXTsuj/resources/app.asar/main.js:168:3)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:782621) UnhandledPromiseRejectionWarning: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
    at doWrite (_stream_writable.js:427:19)
    at writeOrBuffer (_stream_writable.js:415:5)
    at WriteStream.Writable.write (_stream_writable.js:305:11)
    at fn (/tmp/.mount_obsidiGXTsuj/resources/app.asar/main.js:37:10)
    at update (/tmp/.mount_obsidiGXTsuj/resources/app.asar/main.js:168:3)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:782621) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:782621) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:782621) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

P.S: it would also be nice if when opening a note this way, the note’s text will be in focus so I can instantly write or search/navigate with the keyboard to where I want.

Environment

  • Operating system: Linux Manjaro
  • Obsidian version: 0.9.2

Additional information

A couple of questions:

  • Are you using the AppImage or snap?
  • What’s your installer version?
  • Did you try encoding the underscore in the filename? I’m not sure if this is needed, but it can’t hurt to double check

That’s an important point that I didn’t consider.
I was with a very old installer and upgrading it helped a great deal.
With the 0.9.2 installer, the command does exit, yet still with an error (after properly opening the file):

(electron) 'allowRendererProcessReuse' is deprecated and will be removed.
Loading main app package /tmp/.mount_obsidirsKAr7/resources/obsidian.asar

undefined:0

illegal access
(Use `node --trace-uncaught ...` to show where the exception was thrown)

It’s an AppImage, and there are no underscores or any special symbols in the filename.

That message is “normal” and unrelated to the URL, so you should be good to go!

Great, issue closed :slight_smile:

The original concept of promises was that you could have a rejected promise sitting around for some time before attaching a catch handler to it. For example, Firefox used to warn of uncaught rejection errors only when a rejected promise with no rejection handler was garbage collected from memory.

Somebody decided that JavaScript programmers couldn’t be trusted with managing promise rejections properly and changed the HTML spec to require browsers to throw “unhandled promise rejection” errors if a rejected promise has no rejection handlers added before code returns to the event loop.

On a case by case basis you can prevent the host being notified by adding a rejection handler that is never used. The reasoning is that adding a dummy rejection handler to a promise means that should it be rejected it has a rejection handler already - or if it was rejected the host is notified the promise now has a rejection handler - and you can call then and catch multiple times on the same promise.

A nice way to wait for several Promises to resolve to use the Promise.all function. It expects an Array of Promises, and produces a Promise that resolves to an Array containing the values that the individual Promises resolved to. Furthermore, it only resolves after the last Promise resolves. If any of its input Promises rejects, then the entire Promise.all expression rejects as well. It effectively “runs” all of its input processes “at the same time”, emulating the classic “fork-join” pattern.