klaudhaus / lit-up

Minimal yet scalable state pattern for reactive web apps with lit-html templates
MIT License
16 stars 0 forks source link

Specific handling for unresolved / unresolvable promises #8

Open tstewart-klaudhaus opened 3 years ago

tstewart-klaudhaus commented 3 years ago

It's possible for the result of an async function to never resolve, such as a call to an asynchronous operation that never returns (whether in error state or not), or even to be unresolvable, which is an unusual case that was reproduced by returning a call to an embedded iFrame function that was then unloaded.

In the first case, the rest of the up handling never runs, so there is no further render. Whilst this is perhaps what you'd expect, and does not hinder further operation of subsequent updates (although the current chain will not continue), it would be good to have some detection and warning of this case (a default timeout with console message perhaps) in order to alert the developer that there may some kind of race condition problem, such as calling a service before initialisation.

In the second case, the Chrome error is:

TypeError: Promise resolve or reject function is not callable

Whilst this is accurate, it is not very informative in telling the developer what may be causing the issue. Consider catching and better messaging for this specific case.