Open hsolbrig opened 4 years ago
Full support for @included
is in https://github.com/digitalbazaar/jsonld.js/pull/349.
The issue seems to have been fixed in the above example, but https://tinyurl.com/ura2qxv still has it.
A newer jsonld.js was released and the playground updated. Did that solve this issue?
Unfortunately, I'm getting a hang when I use the above link.
Yup. I was hoping no one would notice. ;-) Locking the whole tab up, which is strange. Maybe something recursive in those contexts? Will have to investigate.
Ya - the contexts are recursive as all getout -- I thought that was ok...
In Node.js it first flips out on https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld.
No special encoding was specified:
$ curl -I https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld
[...]
Content-Type: application/ld+json
[...]
It has BOM bytes:
$ file medicationadministration.context.jsonld
medicationadministration.context.jsonld: UTF-8 Unicode (with BOM) text
$ curl -O https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld
$ xxd -l 16 medicationadministration.context.jsonld
00000000: efbb bf7b 0a20 2022 4063 6f6e 7465 7874 ...{. "@context
JSON.parse
isn't liking that in node:
[...]
name: 'jsonld.InvalidUrl',
details: {
code: 'loading remote context failed',
url: 'https://fhircat.org/fhir/contexts/r5/medicationadministration.context.jsonld',
cause: SyntaxError: Unexpected token in JSON at position 0
at JSON.parse (<anonymous>)
at ContextResolver._fetchContext (.../jsonld.js/lib/ContextResolver.js:159:24)
[...]
I have no idea what tools should do with that. It's easy enough to fix, if that's the right thing to do. I don't know. I think browser is ok with it. In Node it then proceeds to blow it's heap limits and crash the vm. I assume that's what happens in the browser as well. So somewhere recursion is not handled well.
Working on a scoped context recursion fix: https://github.com/digitalbazaar/jsonld.js/pull/381
Playground has been updated. Failing to load the files, but I think that's just due to the BOM character issue.
See: http://tinyurl.com/r8chydx
If the
@context
entry precedes the@included
, behavior is as expected. If at the end,@included
maps tohttp://example.org/@included