Open mjjo53 opened 4 years ago
Hi @mjjo53, thanks for reporting this. Do you have some thoughts on what a fix would look like, or are you interested in contributing one? I’m interested in helping getting this working, but it will go much faster getting a fix done if you can drive this.
I just realised that I actually also ran into this issue on one of my projects, and solved it by manually re-setting the engine whenever calling render
:
def render_markdown(content_state):
DOM.use(ENGINE)
return exporter.render(content_state)
Does that seem like a viable solution to you? I think I might add this directly in exporter.render
if so, so we can solve this without having to change how this code is structured too much.
@thibaudcolas Your example code is not thread safe.
@bindung yes, as far as I know the whole library isn’t thread-safe, as @mjjo53 initially reported. The code above only helps in a single-threaded environment. Do you have any suggestions for how to fix this properly, or further diagnostic of the problem?
First of all, I would like to thank you as someone who is using this library. I'm using this library with a markdown version. (draftjs_exporter_markdown) Because the dom of draftjs_exporter.dom.DOM is a class-level variable, it could be a problem depending on the timing of creating two versions of the HTML object. Furthermore, I'm using this on a web server, this can cause bigger problems in a multithreaded environment. Not only the markdown version, but the 3 engines built-in draftjs_exporter will cause the same problem.
Could you solve this problem? Attached test code and results.
output: