Closed smessie closed 6 months ago
Don't see anything wrong there at first glance. This should be a good starting point for debugging: https://github.com/comunica/comunica-feature-link-traversal/blob/master/packages/actor-extract-links-predicates/lib/ActorExtractLinksPredicates.ts#L25
I'm really lost. I first tried debugging by npm linking comunica in the project, but in the end I started debugging using the command line version of the locally cloned comunica LTQP repo. However, that gave correct results, as well as the online browser version.
I continued debugging and made JavaScript versions in plain Node, with Vite and with Vue. They can be found here: https://github.com/smessie/comunica-ltqp-debugging
With just Node, I get the correct results as expected, with Vite and Vue however, the query results in no results and does not follow any links (if you look in the network tab of your browser).
Any ideas on the cause for this?
After some more hours of debugging I found a workaround by accident while making the console.log in Comunica working (it also made Comunica Link Traversal working 😄)
By configuring the NodeModulesPolyfillPlugin
in the vite.config.js, it resolved yet another incompatibility with porting the NodeJS targeted comunica to the browser.
export default defineConfig({
optimizeDeps: {
esbuildOptions: {
plugins: [
NodeModulesPolyfillPlugin(),
],
}
}
})
See also https://github.com/smessie/comunica-ltqp-debugging/commit/e937234bbdd04bb301cbbaa70ed7ed59cf57afe2 to see how the MRE now works with this extra configuration.
The warning that appeared in the browser console (which I unfortunately was ignoring at first) should explain more on the specific underlying issue.
browser-external:util:9 Module "util" has been externalized for browser compatibility. Cannot access "util.debuglog" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
get @ browser-external:util:9
node_modules/readable-web-to-node-stream/node_modules/readable-stream/lib/_stream_readable.js @ _stream_readable.js:55
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/readable-web-to-node-stream/node_modules/readable-stream/readable-browser.js @ readable-browser.js:1
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/readable-web-to-node-stream/lib/index.js @ index.js:4
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/bus-http/lib/ActorHttp.js @ ActorHttp.ts:3
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/bus-http/lib/index.js @ index.ts:1
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/actor-http-fetch/lib/ActorHttpFetch.js @ ActorHttpFetch.ts:2
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/actor-http-fetch/lib/index.js @ index.ts:1
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/query-sparql-link-traversal-solid/engine-default.js @ engine-default.js:313
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/query-sparql-link-traversal-solid/lib/QueryEngine.js @ QueryEngine.ts:4
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/query-sparql-link-traversal-solid/lib/index-browser.js @ index-browser.ts:3
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
(anonymous)
and
Module "util" has been externalized for browser compatibility. Cannot access "util.inspect" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
get @ browser-external:util:9
node_modules/readable-web-to-node-stream/node_modules/readable-stream/lib/internal/streams/buffer_list.js @ buffer_list.js:14
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/readable-web-to-node-stream/node_modules/readable-stream/lib/_stream_readable.js @ _stream_readable.js:62
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/readable-web-to-node-stream/node_modules/readable-stream/readable-browser.js @ readable-browser.js:1
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/readable-web-to-node-stream/lib/index.js @ index.js:4
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/bus-http/lib/ActorHttp.js @ ActorHttp.ts:3
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/bus-http/lib/index.js @ index.ts:1
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/actor-http-fetch/lib/ActorHttpFetch.js @ ActorHttpFetch.ts:2
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/actor-http-fetch/lib/index.js @ index.ts:1
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/query-sparql-link-traversal-solid/engine-default.js @ engine-default.js:313
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/query-sparql-link-traversal-solid/lib/QueryEngine.js @ QueryEngine.ts:4
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
node_modules/@comunica/query-sparql-link-traversal-solid/lib/index-browser.js @ index-browser.ts:3
__require2 @ chunk-7REXU52E.js?v=c085e4a3:19
(anonymous)
It looks like it could be related to readable-web-to-node-stream
using readable-stream
version 3.x and not 4.x, and the 3.x versions seem to be using those functions from util
without providing their own polyfills.
No idea how to fix that, since there is no newer version available of that readable-web-to-node-stream
package that would use a newer readable-stream
.
We seem to be using that package in our base http bus here: https://github.com/search?q=repo%3Acomunica%2Fcomunica%20readable-web-to-node-stream&type=code The package doesn't seem to be maintained anymore. But since it's licensed under MIT, we can probably fork it, and depend on the latest readable-stream version. Something one of you want to look into @smessie or @surilindur? (probably only after the ESWC deadlines 😉)
After updating the dependencies, I've realised that this update to the @smessie/readable-web-to-node-stream@^3.0.3
works, but however not only the base http bus is using that package, but also the fetch-sparql-endpoint.js library used by some actors which will also have to update to the newest fetch-sparql-endpoint version once https://github.com/rubensworks/fetch-sparql-endpoint.js/pull/72 gets merged.
Edit: well, actually that last step should not be needed as doing a clean npm/yarn install should update to the newest version of the fetch-sparql-endpoint dependency then.
Another day, another update.
With all dependencies updated to their latest versions, I still need to polyfill the global
variable before LTQP is working.
I've updated my example app to deliver a reproducible example: https://github.com/smessie/comunica-ltqp-debugging/tree/main/vue
With global
being polyfilled:
The 4 expected results are being returned by following the ldp:contains links in the initial resource.
Without global
being polyfilled:
Zero results are being returned, and you can notice that only the initial resource is being retrieved and no other links are being followed.
To try out yourself, you can use the Vue application in my comunica-ltqp-debugging repository and comment (no results) / uncomment (the 4 expected results) the global
polyfill.
The thing is however, where previously there was an error or warning pointing out where a not polyfilled variable was being used, now there are no errors in the console, making it hard to find the root cause of the issue.
AFAIK, we use globalThis
everywhere. Maybe some of our deps is using global
instead of globalThis
?
Maybe yes, but I can't seem to find any.
Issue type:
Description:
Link traversal is not performed. It only requests the link that is provided in the context's sources, even though it should follow other links as that document contains ldp:contains triples.
The code in my Web client app:
With this the query being executed after filling in the javascript variables (printed via console log to make sure that the query is what I think it is):
The content of
http://localhost:3000/researcher-test/ldesinldp/#EventStream
:Content of
http://localhost:3000/researcher-test/ldesinldp/1693558885201/
:In the network tab of my browser I can witness only
http://localhost:3000/researcher-test/ldesinldp/
being requested. When I however manually addfragmentUri
(=http://localhost:3000/researcher-test/ldesinldp/1693558885201/
) to the context's sources, the query executes as it is supposed to and find all expected results. This should prove that my query is correct. I would however expect link traversal to find its way to this (fragmentUri) resource by either following ldp:contains or the link in the query.Environment:
"@comunica/query-sparql-link-traversal-solid": "^0.2.0"
(package-lock.json and node_modules removed and installed again)Running in Web client environment (Vue with Vite)
Crash log: