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

Uncaught (in promise) Error: missing a title #86

Open
sebilasse opened this issue Nov 8, 2022 · 4 comments
Open

Uncaught (in promise) Error: missing a title #86

sebilasse opened this issue Nov 8, 2022 · 4 comments

Comments

@sebilasse
Copy link

  • wikibase-sdk version: latest
  • Environment: deno

redaktor is currently learning the planet earth including administrative or touristic hierarchies and connecting OSM relation, wikidata id, geonames etc.
When I looked for the following
[
"Q1844", "Q49651",
"Q49654", "Q49655",
"Q49657", "Q49659",
"Q49660", "Q49661",
"Q49662", "Q4540",
"Q49663", "Q27439086",
"Q27439070", "Q4191863",
"Q593158", "Q991615",
"Q27439073", "Q816776"
]
and used getManyEntities .then simplify [without options]
then I got

error: Uncaught (in promise) Error: missing a title at Object.yr [as getSitelinkUrl] (https://esm.sh/v96/wikibase-sdk@8.0.5/deno/wikibase-sdk.js:4:5206)

I see that it is coming from simplify (which I'll try/catch too as workaround) in my code

fetch(wikibase-sdk-url, { headers }).then((r) => {
    if (!r.ok) resolve([]);
    return r.json();
  }).then((res: any) => {
    if (!res) resolve([]);
    const { entities } = res;
    resolve(wikidata.simplify.entities(entities));
  }).catch(() => {
    resolve([]);
  });
@EdJoPaTo
Copy link
Contributor

As this library is completely without async / Promises the uncaught promise error is unrelated to this library. Using try catch and await is way easier to manage than your .then / .catch method chain.

try {
  const response = await fetch(url, {headers});
  const { entities } = await response.json();
  const simplified = wdk.simplify.entities(entities);
} catch {}

Would be interesting which Q id exactly caused this to debug this.

@sebilasse
Copy link
Author

Sorry, I do not understand.
The import './simplify.js' is from this library.

If I give wikidata.simplify.entities(entities) the same statically, the error is the same.
It is just an uncaught promise error cause it is in a promise.

@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented Apr 8, 2023

Yes, the simplifyEntities method is from this library but this library does not use any promise. Therefore it can not produce an uncaught promise which means the uncaught promise must be created somewhere else in your code or another library you use.

Personally I would rewrite your code with the await keyword and the try catch around it as I suspect a missing catch in there and it’s just way easier to read/understand. (Like the example in my last response)

I hope I could rephrase my response well enough?

@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented Apr 9, 2023

Ok, the title of this issue is very misleading. It’s not at all about the uncaught promise.

Can you specify which Item ID fails exactly? Also it looks like Deno is using a minified version without source map. So it’s not entirely clear where exactly it’s happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants