o-development / ldo

Monorepo for Linked Data Objects (ldo)
MIT License
22 stars 5 forks source link

Failed to load remote context when trying to run `ldo build` on many shex shapes #43

Open jeswr opened 1 month ago

jeswr commented 1 month ago

When trying to run npm run build on https://github.com/jeswr/microsoft-kg-as-rdf the following error consistently occurs:

> email_api_test@1.0.0 build
> ldo build --input ./shex --output ./ldo

◠ Generating LDO Documents/home/jeswr/Documents/GitHub/jeswr/email_api_test/node_modules/jsonld-context-parser/lib/ContextParser.js:722
            throw new ErrorCoded_1.ErrorCoded(`Failed to load remote context ${url}: ${e.message}`, ErrorCoded_1.ERROR_CODES.LOADING_REMOTE_CONTEXT_FAILED);
                  ^

ErrorCoded: Failed to load remote context http://www.w3.org/ns/shex.jsonld: fetch failed
    at ContextParser.load (/home/jeswr/Documents/GitHub/jeswr/email_api_test/node_modules/jsonld-context-parser/lib/ContextParser.js:722:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
    at async ContextParser.parse (/home/jeswr/Documents/GitHub/jeswr/email_api_test/node_modules/jsonld-context-parser/lib/ContextParser.js:588:58) {
  code: 'loading remote context failed'
}

Node.js v20.11.0

I suspect the best fix would be to use a custom document loader to cache http://www.w3.org/ns/shex.jsonld and supply that context to jsonld-context-parser. A brief look indicates that the jsonld-context-parser call is coming from the https://github.com/o-development/jsonld2graphobject dependency.

jeswr commented 1 month ago

I would also recommend using the https context rather than the http context which redirects to the https context.