asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!
https://kroki.io/
MIT License
146 stars 47 forks source link

Unable to generate diagrams with Kroki using POST method #448

Open jay-blanc opened 3 months ago

jay-blanc commented 3 months ago

Hello,

I'm facing an issue generating diagrams :

The result is the diagram generation is completely stucked. Indeed, the reading of the HTTP response is never done and the generation of the whole documentation never achieved.

This behaviour never occurred using the GET method (thus it works only with light plantuml diagrams but not huge plantuml diagrams or complex vega diagrams for example).

Looking the source code of the asciidoctor-kroki extension, I saw the use of synchronous XMLHttpRequest (using the xhr.open(method, uri, false) settings) which seems to be deprecated. I tried using the asynrchonous way but it seems there's a lot of impacts in the source code of the extension.

Did you reproduce it ? Could you please help me solving this issue ?

PS : the kroki server I run manually is OK as I'm able to generate huge diagrams using POST method through Postman for example. So it really comes from the extension (version 0.17.0).

ggrossetie commented 3 months ago

I tried using the asynrchonous way but it seems there's a lot of impacts in the source code of the extension.

Asciidoctor.js is synchronous and Asciidoctor extensions are also synchronous so it won't work. If you are using this extension in Antora, you will actually use this implementation https://github.com/ggrossetie/unxhr (synchronous HTTP request in Node.js).

Did you reproduce it ? Could you please help me solving this issue ?

I can help you but you will need to provide a simple/minimal reproduction case.

jay-blanc commented 3 months ago

Asciidoctor.js is synchronous and Asciidoctor extensions are also synchronous so it won't work.

I totally agree.

I can help you but you will need to provide a simple/minimal reproduction case.

For sure, here is a full example :

Kroki as a Docker container

version: "3"
services:
  core:
    image: registry.hub.docker.com/yuzutech/kroki
    ports:
      - "8000:8000"

Antora playbook

https://github.com/jay-blanc/antora-playbook.git

asciidoc:
  attributes:
    # Using Kroki as a Docker container
    kroki-server-url: http://<SET_HERE_YOUR_KROKI_SERVER>:8000
    # Diagram generation during build process
    kroki-fetch-diagram: true
    # Force POST method requesting Kroki server
    kroki-http-method: post

Result

$ npx antora generate --stacktrace --log-level=all antora-playbook.yml
{ includePaths: [] }

Then it's stucked on { includePaths: [] } on POST call. Setting it as a GET, the generation can succeed.

ggrossetie commented 2 months ago

Thanks, I will try to reproduce this issue this week 😉