asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!

Home Page:https://kroki.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to generate diagrams with Kroki using POST method

jay-blanc opened this issue · comments

Hello,

I'm facing an issue generating diagrams :

  • with Antora and Kroki
  • using the asciidoctor-kroki extension
  • using the POST method (either setting the "kroki-http-method" in the Antora playbook or using huge diagrams (which force the use of the POST method))

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).

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.

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.

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