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

Earmark.Global.Messages not started #147

Closed
qcam opened this issue Jun 6, 2017 · 8 comments
Closed

Earmark.Global.Messages not started #147

qcam opened this issue Jun 6, 2017 · 8 comments
Assignees
Labels

Comments

@qcam
Copy link

qcam commented Jun 6, 2017

My application uses Earmark in compile time and some times I get this error.

** (exit) exited in: GenServer.call(Earmark.Global.Messages, {:get, #Function<2.2630312/1 in Earmark.Global.Messages.get_all_messages/0>}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

Have anyone encountered this before? Perhaps we need a way to supervise the agent?

@RobertDober
Copy link
Collaborator

RobertDober commented Jun 7, 2017

Thank you for reporting this. Unfortunately I am only an OTP beginner, but the decision to use an agent for error messages has been taken because failure is acceptable (within certain limits of course).

My question is: Is the occasional failure a nuisance.

@ericmj
Copy link

ericmj commented Jun 7, 2017

The problem seems to be that earmark doesn't support being called from multiple processes concurrently. If you need to use a global, named agent I would suggest starting it in the application supervisor and storing error messages for each process instead of breaking when the agent is used from two processes concurrently.

@qcam
Copy link
Author

qcam commented Jun 7, 2017

@RobertDober @ericmj Thanks for your support.

Is the occasional failure a nuisance.

Personally it's a yes for me, how I occasionally got this error was calling Earmark.as_html/1 from multiple processes in compile time (I was not trying to access the agent manually).

I totally agree that failure should not fail the parsing, but in this case the error was from GenServer because when the agent was not found (when Earmark._as_html() tried to pop_all_messages() I believe).

The problem seems to be that earmark doesn't support being called from multiple processes concurrently.

I believe v1.1 does not have this problem. Sorry for my ignorance but maybe the introduction of
Earmark.Global.Messages wasn't a really nice improvement, since it took away the possibility of concurrent parsing?

And actually I think all texts are valid Markdown from the parser point of view? In that case maybe we don't need error agents?

@RobertDober
Copy link
Collaborator

@qcam I was not aware of this restriction, and if you can go back to 1.1 (or even 1.1.x) please do so.
But I will try to follow @ericmj 's advice (thanx for your ongoing support when my ignorance strikes BTW).

Well even in great programming languages like Elixir/Erlang, Clojure and Haskell, state is still an additional hassle. But I will definitely fix it, maybe getting pure again, not sure yet.

@qcam
Copy link
Author

qcam commented Jun 26, 2017

@RobertDober Thanks for the fix ❤️

@RobertDober
Copy link
Collaborator

@qcam can you live with the github version, or do you want @pragdave to make a release?

@qcam
Copy link
Author

qcam commented Jun 26, 2017

@RobertDober thanks. I think I'm good with 1.1.x so you can release whenever you wish. :)

@RobertDober
Copy link
Collaborator

We appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants