pkg / browser

Package browser provides helpers to open files, readers, and urls in a browser window.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Worked once then fails with low-level macOS error

Integralist opened this issue Β· comments

πŸ‘‹πŸ»

I installed this package, and ran it once and it worked fine. I then came back and tried it again (after making some code changes) and found that no matter what URL I provided to browser.OpenURL the function would error with...

NOTE: I've broken it up over multiple lines for readability.

The application cannot be opened for an unexpected reason, error=
  Error Domain=NSOSStatusErrorDomain 
  Code=-600 "procNotFound: no eligible process with specified descriptor" 
  UserInfo={_LSLine=379, _LSFunction=_LSAnnotateAndSendAppleEventWithOptions}

I've failed to find much useful information on this,
but there is a long thread from another project (which may or may not be useful):
lwouis/alt-tab-macos#704

Hmm. The plot thickens...

I just spent a few minutes committing all my code changes with the intention of restarting my laptop (as I'd seen someone say in the above thread URL that this helped them) and I thought I'd build my code one more time, where I then found it suddenly worked again and the URL I specified was opened in an existing open instance of my default browser.

Not sure what would have happened in that time frame for it to suddenly work again?

One thing I did do, but it didn't help, was I closed my browser and tried running my app again to see if opening the default browser afresh (rather than having the browser already open and the URL opening in a new tab) would work. It didn't work.

Then I wondered if it was because I had Ctrl-c my running go program, because when it started working again (i.e. the URL was opened in a new tab of an existing browser instance) I did a Ctrl-c and then re-ran the go app and again found the error was happening.

So I thought maybe it was because of the fact I've not handled signalling properly in the app and maybe the OS is not releasing some sort of file descriptor for my still open browser.

But then, after waiting a period of like (I dunno, at a guess 5 minutes) and trying to run my go app again (I've not done anything else btw at this point I got distracted googling for answers), it suddently started working again!? So it would appear that there's some sort of OS issue with releasing a resource (whatever that resource is) that's not happening immediately, but when it does the browser.OpenURL will succeed πŸ€”

Additionally, again with no code changes to my program, I was just hammering "up arrow, enter" to run my go program just while I was thinking in my head about the problem and then bang! all of sudden it worked and opened the browser!? But then for a different logic reason my program ended with a os.Exit(1) (rather than ending successfully) and so re-running the program brought me back to the original error again and the browser not opening 🀦🏻 .

And just to clarify, if I force my go app to end cleanly the problem still persists and on the next run of the app the browser will fail to open.

I have also tried https://github.com/toqueteos/webbrowser and found that it just reports:

webbrowser: can't open browser.

I've also tried https://github.com/skratchdot/open-golang with even less error context:

exit status 1

OK, this is replicable outside of the package, just by running open <any url>.

Going to close this now.

I discovered a new terminal instance worked fine every time, and so I then killed my tmux session/server and restarted it and found that my go program works fine every time now too.

Now sure what caused it to go so loopy, but that was frustrating 😬