Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Promise Rejection #45

Open
michielbdejong opened this issue Nov 8, 2019 · 5 comments
Open

Unhandled Promise Rejection #45

michielbdejong opened this issue Nov 8, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@michielbdejong
Copy link
Contributor

I edited the example from the readme to wrap https://github.com/RubenVerborgh/LDflex#looking-up-data-on-the-web in a try-catch, and change the domain name to a non-existing one ending in .orgz:

const { PathFactory } = require('ldflex');
const { default: ComunicaEngine } = require('ldflex-comunica');
const { namedNode } = require('@rdfjs/data-model');

const profileDoc = 'https://ruben.verborgh.orgz/profile/';
const webId = `${profileDoc}#me`;

// The JSON-LD context for resolving properties
const context = {
  "@context": {
    "@vocab": "http://xmlns.com/foaf/0.1/",
    "friends": "knows",
    "label": "http://www.w3.org/2000/01/rdf-schema#label",
  }
};
// The query engine and its source
const queryEngine = new ComunicaEngine(profileDoc);
// The object that can create new paths
const path = new PathFactory({ context, queryEngine });

async function showPerson(person) {
  console.log(`This person is ${await person.name}`);

  console.log(`${await person.givenName} is interested in:`);
  for await (const name of person.interest.label)
    console.log(`- ${name}`);

  console.log(`${await person.givenName} is friends with:`);
  for await (const name of person.friends.givenName)
    console.log(`- ${name}`);
}


(async () => {
  try {
    const ruben = path.create({ subject: namedNode(webId) });
    await showPerson(ruben);
  } catch(e) {
    console.error(e);
  }
  console.log('success');
})();

The result is as follows:

(node:3188) UnhandledPromiseRejectionWarning: FetchError: request to https://ruben.verborgh.orgz/profile/ failed, reason: getaddrinfo ENOTFOUND ruben.verborgh.orgz
    at ClientRequest.<anonymous> (/Users/michiel/gh/solid/query-ldflex/node_modules/node-fetch/index.js:133:11)
    at ClientRequest.emit (events.js:203:13)
    at TLSSocket.socketErrorListener (_http_client.js:399:9)
    at TLSSocket.emit (events.js:203:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
(node:3188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
(node:3188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:3188) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 8)
(node:3188) UnhandledPromiseRejectionWarning: FetchError: request to https://ruben.verborgh.orgz/profile/ failed, reason: getaddrinfo ENOTFOUND ruben.verborgh.orgz
    at ClientRequest.<anonymous> (/Users/michiel/gh/solid/query-ldflex/node_modules/node-fetch/index.js:133:11)
    at ClientRequest.emit (events.js:203:13)
    at TLSSocket.socketErrorListener (_http_client.js:399:9)
    at TLSSocket.emit (events.js:203:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
(node:3188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 9)

Am I doing something wrong? Could this be related to LDflex/Query-Solid#30 ?
This code works correctly when you change 'rubenverborgh.orgz' back to 'rubenverborgh.org'.

@RubenVerborgh RubenVerborgh added the bug Something isn't working label Nov 8, 2019
@RubenVerborgh
Copy link
Member

Am I doing something wrong?

Nope, LDflex does 🙂 Thanks for the testcase.

@michielbdejong
Copy link
Contributor Author

OK! I'm diving in to fix this. The code is quite hard to read for me so far, but making progress. https://github.com/RubenVerborgh/LDflex/blob/master/src/defaultHandlers.js#L25 seems to be what is adding the Promise behaviour, so maybe that gives me a route to where I can add some error handling for this.

@RubenVerborgh
Copy link
Member

My suspicion is that the error will actually be down in Comunica (given that Comunica is the one doing the fetching, and that we are not getting back a Comunica error). It might be this module: https://github.com/comunica/actor-http-solid-auth-fetch

@RubenVerborgh
Copy link
Member

Upon closer inspection, this issue is indeed a duplicate of LDflex/Query-Solid#30. The root cause is comunica/comunica#565.

@rubensworks
Copy link
Collaborator

Should be fixed in Comunica 1.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants