What is Nostr?
Alex /
npub1q3s…d26p
2024-10-10 02:27:57

Alex on Nostr: Let me tell you what I learned about JavaScript today, that I wish I didn't have to. ...

Let me tell you what I learned about JavaScript today, that I wish I didn't have to. If you create a rejected promise, and you put it in a variable, and you don't catch the promise in the same tick, it results in an "unhandled promise rejection" that crashes your entire application. Also, if it's not an "Error" instance that rejects (but rather a different type of primitive or object), you don't even get a stack trace. You get an error like this:

error: Uncaught (in promise) null

With absolutely no other information. Your application is crashed and you have no idea how to fix it. And you'd better pray you logged the right stuff above it to use context clues to figure it out.

Anyway, here is the problem code (left) and the fixed solution (right).


Author Public Key
npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p